[gcc r15-10356] Deal with prior EH/abormal cleanup when fixing up noreturn calls
Richard Biener
rguenth@gcc.gnu.org
Wed Sep 24 09:46:59 GMT 2025
https://gcc.gnu.org/g:732c0a78740860340c58f32bab5bf215d9032007
commit r15-10356-g732c0a78740860340c58f32bab5bf215d9032007
Author: Richard Biener <rguenther@suse.de>
Date: Wed Sep 10 17:14:07 2025 +0200
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.
(cherry picked from commit 5c4f1313e753aeb6920a48c62c7c99ad36e1adae)
Diff:
---
gcc/testsuite/g++.dg/torture/pr121870.C | 20 ++++++++++++++++++++
gcc/tree-ssa-propagate.cc | 2 ++
2 files changed, 22 insertions(+)
diff --git a/gcc/testsuite/g++.dg/torture/pr121870.C b/gcc/testsuite/g++.dg/torture/pr121870.C
new file mode 100644
index 000000000000..8f4e7ab50696
--- /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 ec2068948215..872f881b644c 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 ");
More information about the Gcc-cvs
mailing list