]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/109410 - ICE with noreturn and -g
authorRichard Biener <rguenther@suse.de>
Thu, 29 Jan 2026 14:43:01 +0000 (15:43 +0100)
committerRichard Biener <rguenther@suse.de>
Fri, 30 Jan 2026 06:59:04 +0000 (07:59 +0100)
This fixes the -g variant of the original testcase.

PR tree-optimization/109410
* tree-ssa-reassoc.cc (build_and_add_sum): Use
gsi_start_nondebug_after_labels_bb to look for a possible
returns-twice call.

* gcc.dg/pr109410-2.c: New testcase.

gcc/testsuite/gcc.dg/pr109410-2.c [new file with mode: 0644]
gcc/tree-ssa-reassoc.cc

diff --git a/gcc/testsuite/gcc.dg/pr109410-2.c b/gcc/testsuite/gcc.dg/pr109410-2.c
new file mode 100644 (file)
index 0000000..9dd8d09
--- /dev/null
@@ -0,0 +1,5 @@
+/* PR tree-optimization/109410 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -g" } */
+
+#include "pr109410.c"
index d2d2e084aa6a37242e3f3143244fe139de449075..7abbf195520bc6c93015bc11bda14e0b6aa97507 100644 (file)
@@ -1568,7 +1568,8 @@ build_and_add_sum (tree type, tree op1, tree op2, enum tree_code opcode)
   if ((!op1def || gimple_nop_p (op1def))
       && (!op2def || gimple_nop_p (op2def)))
     {
-      gsi = gsi_after_labels (single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun)));
+      gsi = gsi_start_nondebug_after_labels_bb
+               (single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun)));
       if (!gsi_end_p (gsi)
          && is_gimple_call (gsi_stmt (gsi))
          && (gimple_call_flags (gsi_stmt (gsi)) & ECF_RETURNS_TWICE))