https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71109

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
To me this looks like invalid jump optimization.  In *.csa we have:
(jump_insn 27 26 28 3 (set (pc)
        (if_then_else (ne (reg:CCZ 17 flags)
                (const_int 0 [0]))
            (label_ref 97)
            (pc))) 635 {*jcc_1}
     (expr_list:REG_DEAD (reg:CCZ 17 flags)
        (int_list:REG_BR_PROB 450 (nil)))
 -> 97)
...
(note 28 27 137 5 [bb 5] NOTE_INSN_BASIC_BLOCK)
(insn/f 137 28 138 5 (set (mem:DI (pre_dec:DI (reg/f:DI 7 sp)) [0  S8 A8])
        (reg:DI 3 bx)) pr71109.c:19 -1
     (expr_list:REG_DEAD (reg:DI 3 bx)
        (nil)))
(note 138 137 30 5 NOTE_INSN_PROLOGUE_END)
...
(jump_insn 129 94 130 5 (set (pc)
        (label_ref 122)) 667 {jump}
     (nil)
 -> 122)
;;  succ:       7 [100.0%]
...
(barrier 130 129 97)
...
(code_label 97 130 98 6 3 "" [1 uses])
...
(code_label 122 146 123 7 4 "" [1 uses])
(note 123 122 124 7 [bb 7] NOTE_INSN_BASIC_BLOCK)
;;  succ:

The bb7 is from __builtin_unreachable () that has been added.
But, in *.jump we have at the end of the (former bb5, now bb4):
(insn 71 69 97 4 (set (mem/c:QI (const:DI (plus:DI (symbol_ref:DI ("a") [flags
0x2]  <var_decl 0x7ffff7ff9cf0 a>)
                    (const_int 32 [0x20]))) [2 MEM[(struct S0 *)&a + 32B]+0 S1
A32])
        (reg:QI 1 dx [orig:99 p2$f8 ] [99])) pr71109.c:37 89 {*movqi_internal}
     (expr_list:REG_DEAD (reg:QI 1 dx [orig:99 p2$f8 ] [99])
        (nil)))
;;  succ:       5 [100.0%]  (FALLTHRU)
...
(code_label 97 71 98 5 3 "" [1 uses])
(note 98 97 103 5 [bb 5] NOTE_INSN_BASIC_BLOCK)

so while previously the basic block with prologue and missing epilogue (because
ending in __builtin_unreachable ()) ended up nowhere, now it falls through into
a bb that is reachable without the prologue being done.
I think in this simple case we should have just removed the edge, so it
wouldn't fallthrough into the next bb (i.e. no edges), but generally, I'm
afraid various __builtin_unreachable () RTL optimizations (where it is
expressed just by missing edges) could be also problematic.

Reply via email to