diff options
author | Andrew Pinski <andrew.pinski@oss.qualcomm.com> | 2025-08-11 20:47:30 +0000 |
---|---|---|
committer | Andrew Pinski <andrew.pinski@oss.qualcomm.com> | 2025-08-12 08:06:23 +0000 |
commit | 2fe432175ef135037dea210002881a093f328779 (patch) | |
tree | 713a8513ee921d5dd83b30aed3ec07fd9d551943 /gcc | |
parent | 1786be14e94bf1a7806b9dc09186f021737f0227 (diff) | |
download | gcc-2fe432175ef135037dea210002881a093f328779.zip gcc-2fe432175ef135037dea210002881a093f328779.tar.gz gcc-2fe432175ef135037dea210002881a093f328779.tar.bz2 |
forwprop: Fix non-call exceptions some more with copy prop for aggregates [PR121494]
Note this conflicts with my not yet approved patch for copy prop for aggregates into
function arguments (I will get back to that soon).
So the problem here is that I assumed if:
*a = decl1;
would not cause an exception that:
decl2 = *a;
would cause not cause one too.
I was wrong, in some cases where the Ada front-end marks `*a` in the store
as TREE_THIS_NOTRAP (due to knowing never be null or some other cases).
So that means when we prop decl1 into the statement storing decl2, we need to
mark that statement as possible to cleanup for eh.
Bootstraped and tested on x86_64-linux-gnu.
Also tested on x86_64-linux-gnu with a hack to force generate LC constant decls in the gimplifier.
PR tree-optimization/121494
gcc/ChangeLog:
* tree-ssa-forwprop.cc (optimize_agr_copyprop): Mark the bb of the use
stmt if needed for eh cleanup.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/tree-ssa-forwprop.cc | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/tree-ssa-forwprop.cc b/gcc/tree-ssa-forwprop.cc index 1cde5f8..4237a20 100644 --- a/gcc/tree-ssa-forwprop.cc +++ b/gcc/tree-ssa-forwprop.cc @@ -1487,6 +1487,7 @@ optimize_agr_copyprop (gimple_stmt_iterator *gsip) fprintf (dump_file, "after previous\n "); print_gimple_stmt (dump_file, stmt, 0, dump_flags); } + gimple *orig_stmt = use_stmt; gimple_stmt_iterator gsi = gsi_for_stmt (use_stmt); gimple_assign_set_rhs_from_tree (&gsi, unshare_expr (src)); update_stmt (use_stmt); @@ -1496,6 +1497,10 @@ optimize_agr_copyprop (gimple_stmt_iterator *gsip) fprintf (dump_file, "into\n "); print_gimple_stmt (dump_file, use_stmt, 0, dump_flags); } + + /* Mark the bb for eh cleanup if needed. */ + if (maybe_clean_or_replace_eh_stmt (orig_stmt, use_stmt)) + bitmap_set_bit (to_purge, gimple_bb (stmt)->index); statistics_counter_event (cfun, "copy prop for aggregate", 1); changed = true; } |