[gcc r13-10463] tree-optimization/124130 - fixup noreturn calls during inlining

Richard Biener via Gcc-cvs <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:13eb29fc195bca0986d6034c33aa79d4badb3c6d

commit r13-10463-g13eb29fc195bca0986d6034c33aa79d4badb3c6d
Author: Richard Biener <[email protected]>
Date:   Tue Feb 17 11:42:44 2026 +0100

    tree-optimization/124130 - fixup noreturn calls during inlining
    
    When we are altering the ctrl state of a stmt due to adding abnormal
    edges from it we also have to make sure to cleanup its noreturn state.
    
            PR tree-optimization/124130
            * tree-inline.cc (copy_edges_for_bb): Fixup noreturn calls
            with abnormal edge source.
    
            * g++.dg/torture/pr124130.C: New testcase.
    
    (cherry picked from commit f34a8411afefac46233d7479131d7e5458ecf57d)

Diff:
---
 gcc/testsuite/g++.dg/torture/pr124130.C | 15 +++++++++++++++
 gcc/tree-inline.cc                      |  3 +++
 2 files changed, 18 insertions(+)

diff --git a/gcc/testsuite/g++.dg/torture/pr124130.C b/gcc/testsuite/g++.dg/torture/pr124130.C
new file mode 100644
index 000000000000..0eb08c6b63a1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr124130.C
@@ -0,0 +1,15 @@
+// { dg-do compile }
+
+void __sigsetjmp_cancel() __attribute__((__returns_twice__));
+struct basic_ostream {
+  basic_ostream &operator<<(basic_ostream &__pf(basic_ostream &)) {
+    return __pf(*this);
+  }
+} cerr;
+extern "C" void _exit(int);
+enum { Exit_Internal_Error };
+basic_ostream &report_error(basic_ostream &) { _exit(Exit_Internal_Error); }
+void thread_pool_thread_main() {
+  __sigsetjmp_cancel();
+  cerr << report_error;
+}
diff --git a/gcc/tree-inline.cc b/gcc/tree-inline.cc
index 1d11e85bce45..f97344b59d18 100644
--- a/gcc/tree-inline.cc
+++ b/gcc/tree-inline.cc
@@ -2683,6 +2683,9 @@ copy_edges_for_bb (basic_block bb, profile_count num, profile_count den,
 	      make_single_succ_edge (copy_stmt_bb, abnormal_goto_dest,
 				     EDGE_ABNORMAL);
 	      gimple_call_set_ctrl_altering (copy_stmt, true);
+	      if (is_a <gcall *> (copy_stmt)
+		  && (gimple_call_flags (copy_stmt) & ECF_NORETURN))
+		fixup_noreturn_call (copy_stmt);
 	    }
 	}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.