https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124454
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So yes REG_EH_REGION and the corresponding eh edge is being removed (inside
split3) but while calling find_many_sub_basic_blocks which calls
purge_dead_edges. And that leaves behind the unreachable block.
I am trying to figure if we should just call cleanup_cfg unconditionally if
something changed after the call to find_many_sub_basic_blocks or not.
But the real issue is inside copy_hardreg. We are just delaying the who might
catch it.
Where we change:
(insn 69 62 183 6 (set (reg:SI 1 x1 [orig:107 _12 ] [107])
(zero_extend:SI (mem:QI (reg/f:DI 1 x1 [150]) [0 MEM[(char *)_4]+0 S1
A64]))) "/app/example.cpp":8:7 discrim 1 149 {*zero_extendqisi2_aarch64}
(expr_list:REG_EH_REGION (const_int 2 [0x2])
(nil)))
into:
(insn 69 62 183 6 (set (reg:SI 1 x1 [orig:107 _12 ] [107])
(zero_extend:SI (mem:QI (plus:DI (reg/f:DI 31 sp)
(const_int 56 [0x38])) [0 MEM[(char *)_4]+0 S1 A64])))
"/app/example.cpp":8:7 discrim 1 149 {*zero_extendqisi2_aarch64}
(expr_list:REG_EH_REGION (const_int 2 [0x2])
(nil)))
And that no longer traps.