https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96536
Bug ID: 96536
Summary: -fcf-protection code in i386.md:restore_stack_nonlocal
uses invalid compare-and-jump rtl
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: rsandifo at gcc dot gnu.org
Target Milestone: ---
Target: x86_64
Noticed while working on an optimisation that the
-fcf-protection code in restore_stack_nonlocal uses
a branch based on a clobber result:
(insn 14 13 15 2 (parallel [
(set (reg:DI 85)
(minus:DI (reg:DI 85)
(mem:DI (plus:DI (reg/f:DI 82)
(const_int 16 [0x10])) [2 S8 A8])))
(clobber (reg:CC 17 flags))
]) "gcc/testsuite/gcc.target/i386/cet-sjlj-1.c":16:3 -1
(nil))
(jump_insn 15 14 40 2 (set (pc)
(if_then_else (eq (reg:CCZ 17 flags)
(const_int 0 [0]))
(label_ref 28)
(pc))) "gcc/testsuite/gcc.target/i386/cet-sjlj-1.c":16:3 -1
(int_list:REG_BR_PROB 536870916 (nil))
-> 28)
IMO this is invalid RTL. A clobber:
Represents the storing or possible storing of an unpredictable,
undescribed value …
but this usage requires it to be predictable. I think we need
to use the parallel-SET *sub<mode>_2 representation instead.