diff options
author | Thomas Schwinge <tschwinge@baylibre.com> | 2025-05-30 15:06:20 +0200 |
---|---|---|
committer | Thomas Schwinge <tschwinge@baylibre.com> | 2025-05-30 15:06:20 +0200 |
commit | fbde111a3466f3870d00a574700fbb87c56d6c42 (patch) | |
tree | 1fe4e7c74765920cf8f471959baabdc7071e4ebc /gcc | |
parent | 1e21c26f2f53986ad3d5be033ca0098f459bb9e8 (diff) | |
parent | c153150b8a05878191de2ee16c0cce7d526f3c46 (diff) | |
download | gcc-fbde111a3466f3870d00a574700fbb87c56d6c42.zip gcc-fbde111a3466f3870d00a574700fbb87c56d6c42.tar.gz gcc-fbde111a3466f3870d00a574700fbb87c56d6c42.tar.bz2 |
Merge commit 'c153150b8a05878191de2ee16c0cce7d526f3c46' into HEAD
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog.omp | 9 | ||||
-rw-r--r-- | gcc/tree-nrv.cc | 19 |
2 files changed, 21 insertions, 7 deletions
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 <tschwinge@baylibre.com> + + Backported from master: + 2025-05-30 Thomas Schwinge <tschwinge@baylibre.com> + Richard Biener <rguenther@suse.de> + + PR middle-end/119835 + * tree-nrv.cc (pass_nrv::execute): Defuse 'RESULT_DECL' check. + 2025-05-22 Thomas Schwinge <tschwinge@baylibre.com> Backported from master: 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) |