aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorThomas Schwinge <tschwinge@baylibre.com>2025-05-28 18:40:31 +0200
committerThomas Schwinge <tschwinge@baylibre.com>2025-05-30 14:58:55 +0200
commitad212f7025627e49330094a408845bf09fc367a5 (patch)
tree54aac567269dc9c1bd6d2c1e1da93aa047a9a658 /gcc
parent499d610ac358f9b8dd3f788c6728f05ecea7c3e3 (diff)
downloadgcc-ad212f7025627e49330094a408845bf09fc367a5.zip
gcc-ad212f7025627e49330094a408845bf09fc367a5.tar.gz
gcc-ad212f7025627e49330094a408845bf09fc367a5.tar.bz2
Defuse 'RESULT_DECL' check in 'pass_nrv' (for offloading compilation) [PR119835]
... to avoid running into ICEs per PR119835, until that's resolved properly. PR middle-end/119835 gcc/ * tree-nrv.cc (pass_nrv::execute): Defuse 'RESULT_DECL' check. libgomp/ * testsuite/libgomp.oacc-c-c++-common/abi-struct-1.c: '#pragma GCC optimize "-fno-inline"'. * testsuite/libgomp.c-c++-common/target-abi-struct-1.c: New. * testsuite/libgomp.c-c++-common/target-abi-struct-1-O0.c: Adjust. Co-authored-by: Richard Biener <rguenther@suse.de> (cherry picked from commit 543f7e1d59f0b6628e0de6610ad5e1cf7150090b)
Diffstat (limited to 'gcc')
-rw-r--r--gcc/tree-nrv.cc19
1 files changed, 12 insertions, 7 deletions
diff --git a/gcc/tree-nrv.cc b/gcc/tree-nrv.cc
index 180ce39..3be97af 100644
--- a/gcc/tree-nrv.cc
+++ b/gcc/tree-nrv.cc
@@ -167,16 +167,21 @@ pass_nrv::execute (function *fun)
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
{
gimple *stmt = gsi_stmt (gsi);
- tree ret_val;
if (greturn *return_stmt = dyn_cast <greturn *> (stmt))
{
- /* In a function with an aggregate return value, the
- gimplifier has changed all non-empty RETURN_EXPRs to
- return the RESULT_DECL. */
- ret_val = gimple_return_retval (return_stmt);
- if (ret_val)
- gcc_assert (ret_val == result);
+ /* We cannot perform NRV optimizations in a function with an
+ aggregate return value if there is a return that does not
+ return RESULT_DECL. We used to assert this scenario doesn't
+ happen: the gimplifier has changed all non-empty RETURN_EXPRs
+ to return the RESULT_DECL. However, per PR119835 we may run
+ into this scenario for offloading compilation, and therefore
+ gracefully bail out. */
+ if (tree ret_val = gimple_return_retval (return_stmt))
+ {
+ if (ret_val != result)
+ return 0;
+ }
}
else if (gimple_has_lhs (stmt)
&& gimple_get_lhs (stmt) == result)