tree-optimization/109410 - ICE with noreturn and -g

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.
This commit is contained in:
Richard Biener
2026-01-29 15:43:01 +01:00
parent 44a5be2f2d
commit 4fe48225fa
2 changed files with 7 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
/* PR tree-optimization/109410 */
/* { dg-do compile } */
/* { dg-options "-O2 -g" } */
#include "pr109410.c"

View 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))