aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/trans.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2017-05-15 08:43:25 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2017-05-15 08:43:25 +0000
commit13b6b77304b3b3e0ff36c1854d02ef21a0ad16c9 (patch)
treee1fc0da7d351dcdf375d067c1420cbd227793058 /gcc/ada/gcc-interface/trans.c
parent3946f0003c6707fbd4a19533d4e12713f229f349 (diff)
downloadgcc-13b6b77304b3b3e0ff36c1854d02ef21a0ad16c9.zip
gcc-13b6b77304b3b3e0ff36c1854d02ef21a0ad16c9.tar.gz
gcc-13b6b77304b3b3e0ff36c1854d02ef21a0ad16c9.tar.bz2
trans.c (return_value_ok_for_nrv_p): Only apply the addressability check in the constrained case.
* gcc-interface/trans.c (return_value_ok_for_nrv_p): Only apply the addressability check in the constrained case. From-SVN: r248053
Diffstat (limited to 'gcc/ada/gcc-interface/trans.c')
-rw-r--r--gcc/ada/gcc-interface/trans.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c
index 4c80053..abdef03 100644
--- a/gcc/ada/gcc-interface/trans.c
+++ b/gcc/ada/gcc-interface/trans.c
@@ -3238,8 +3238,9 @@ Loop_Statement_to_gnu (Node_Id gnat_node)
RETURN_EXPR [<retval> = Ri]
[...]
- and we try to fulfill a simple criterion that would make it possible to
- replace one or several Ri variables with the RESULT_DECL of the function.
+ where the Ri are not addressable and we try to fulfill a simple criterion
+ that would make it possible to replace one or several Ri variables by the
+ single RESULT_DECL of the function.
The first observation is that RETURN_EXPRs that don't directly reference
any of the Ri variables on the RHS of their assignment are transparent wrt
@@ -3271,8 +3272,8 @@ Loop_Statement_to_gnu (Node_Id gnat_node)
because the anonymous return object is allocated on the secondary stack
and RESULT_DECL is only a pointer to it. Each return object can be of a
different size and is allocated separately so we need not care about the
- aforementioned overlapping issues. Therefore, we don't collect the other
- expressions and skip step #2 in the algorithm. */
+ addressability and the aforementioned overlapping issues. Therefore, we
+ don't collect the other expressions and skip step #2 in the algorithm. */
struct nrv_data
{
@@ -3612,7 +3613,8 @@ return_value_ok_for_nrv_p (tree ret_obj, tree ret_val)
if (TREE_STATIC (ret_val))
return false;
- if (TREE_ADDRESSABLE (ret_val))
+ /* For the constrained case, test for addressability. */
+ if (ret_obj && TREE_ADDRESSABLE (ret_val))
return false;
/* For the constrained case, test for overalignment. */