From ad212f7025627e49330094a408845bf09fc367a5 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Wed, 28 May 2025 18:40:31 +0200 Subject: 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 (cherry picked from commit 543f7e1d59f0b6628e0de6610ad5e1cf7150090b) --- gcc/tree-nrv.cc | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'gcc') 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 (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) -- cgit v1.1 From c153150b8a05878191de2ee16c0cce7d526f3c46 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Fri, 30 May 2025 15:03:59 +0200 Subject: ChangeLog.omp bump --- gcc/ChangeLog.omp | 9 +++++++++ gcc/DATESTAMP.omp | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'gcc') diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp index eaeb97f..b832b2a 100644 --- a/gcc/ChangeLog.omp +++ b/gcc/ChangeLog.omp @@ -1,3 +1,12 @@ +2025-05-30 Thomas Schwinge + + Backported from master: + 2025-05-30 Thomas Schwinge + Richard Biener + + PR middle-end/119835 + * tree-nrv.cc (pass_nrv::execute): Defuse 'RESULT_DECL' check. + 2025-05-22 Thomas Schwinge Backported from master: diff --git a/gcc/DATESTAMP.omp b/gcc/DATESTAMP.omp index 7a70610..ac27433 100644 --- a/gcc/DATESTAMP.omp +++ b/gcc/DATESTAMP.omp @@ -1 +1 @@ -20250522 +20250530 -- cgit v1.1