From: Richard Biener Date: Wed, 10 Sep 2025 15:14:07 +0000 (+0200) Subject: Deal with prior EH/abormal cleanup when fixing up noreturn calls X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5c4f1313e753aeb6920a48c62c7c99ad36e1adae;p=thirdparty%2Fgcc.git Deal with prior EH/abormal cleanup when fixing up noreturn calls When a dead EH or abnormal edge makes a call queued for noreturn fixup unreachable, just skip processing it. PR tree-optimization/121870 * tree-ssa-propagate.cc (substitute_and_fold_engine::substitute_and_fold): Skip removed stmts from noreturn fixup. * g++.dg/torture/pr121870.C: New testcase. --- diff --git a/gcc/testsuite/g++.dg/torture/pr121870.C b/gcc/testsuite/g++.dg/torture/pr121870.C new file mode 100644 index 00000000000..8f4e7ab5069 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr121870.C @@ -0,0 +1,20 @@ +__attribute__((noreturn)) void f1(void) +{ + while(true) {} +} +static void (*fptr)(void) = f1; +struct s1 +{ + ~s1() { + fptr(); + } + void DoInner() { + fptr(); + } +}; + +void f() +{ + s1 xxx; + xxx.DoInner(); +} diff --git a/gcc/tree-ssa-propagate.cc b/gcc/tree-ssa-propagate.cc index ec206894821..872f881b644 100644 --- a/gcc/tree-ssa-propagate.cc +++ b/gcc/tree-ssa-propagate.cc @@ -1019,6 +1019,8 @@ substitute_and_fold_engine::substitute_and_fold (basic_block block) while (!walker.stmts_to_fixup.is_empty ()) { gimple *stmt = walker.stmts_to_fixup.pop (); + if (!gimple_bb (stmt)) + continue; if (dump_file && dump_flags & TDF_DETAILS) { fprintf (dump_file, "Fixing up noreturn call ");