https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120250
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords|ice-on-valid-code |ice-on-invalid-code
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
That testcase is invalid, you can't use computed goto to branch to a function.
And if you meant to jump to the begin_sum local label instead of the function,
you'd need __label__ begin_sum; before that so that when parsing &begin_sum it
would know that begin_sum is a local label and not a function declaration.
Anyway, the ICE is because since r12-4475 combine optimizes the bogus user code
(insn 120 119 121 18 (set (mem/f/c:DI (symbol_ref:DI ("label") [flags 0x2]
<var_decl 0x7f7f86dfb130 label>) [3 label+0 S8 A64])
(symbol_ref:DI ("begin_sum") [flags 0x41] <function_decl
0x7f7f86dcdb00 begin_sum>)) "pr120250.c":24:11 99 {*movdi_internal}
(nil))
(insn 121 120 122 18 (set (reg/f:DI 158)
(symbol_ref:DI ("begin_sum") [flags 0x41] <function_decl
0x7f7f86dcdb00 begin_sum>)) "pr120250.c":25:5 99 {*movdi_internal}
(nil))
(jump_insn 122 121 0 18 (set (pc)
(reg/f:DI 158)) "pr120250.c":25:5 1493 {*indirect_jump}
(expr_list:REG_DEAD (reg/f:DI 158)
(nil)))
where insn 122 is computed_jump_p because it jumps to a REG into:
(jump_insn 122 121 0 18 (set (pc)
(mem/u/c:DI (symbol_ref/u:DI ("*.LC3") [flags 0x2]) [0 S8 A64]))
"pr120250.c":25:5 1493 {*indirect_jump}
(nil))
which no longer matches computed_jump_p which is defined as
/* A subroutine of computed_jump_p, return true if X contains a REG or MEM or
constant that is not in the constant pool and not in the condition
of an IF_THEN_ELSE. */
The MEM in this case is in the constant pool though. So, from rtlanal.cc POV
it is no longer a computed jump, but doesn't have non-NULL JUMP_LABEL_AS_INSN
and isn't a tablejump_p nor asm goto nor returnjump_p either.
To fix the ICE, one possibility would be
--- gcc/dwarf2cfi.cc 2025-04-08 14:08:51.189282728 +0200
+++ gcc/dwarf2cfi.cc 2025-11-19 14:59:39.127356496 +0100
@@ -2690,8 +2690,8 @@ create_trace_edges (rtx_insn *insn)
else
{
rtx_insn *lab = JUMP_LABEL_AS_INSN (insn);
- gcc_assert (lab != NULL);
- maybe_record_trace_start (lab, insn);
+ if (lab != NULL)
+ maybe_record_trace_start (lab, insn);
}
}
else if (CALL_P (insn))
but am not sure I like that too much.