https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88950
Matthew Malcomson <matmal01 at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Known to fail| |5.4.0 --- Comment #5 from Matthew Malcomson <matmal01 at gcc dot gnu.org> --- This problem has been around for a long time -- I have seen the same fundamental problem on gcc 5.4 (when looking for a version to put in the "known to work" field). With "gcc (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.5) 5.4.0 20160609" on the same testcase, the stack_protect_test pattern gets reordered to before the second memory access (the "buf[b] = c" line), and again the stack protection does not guard this memory access. (insn:TI 8 126 16 (parallel [ (set (mem/v/f/c:DI (plus:DI (reg/f:DI 29 x29) (const_int 88 [0x58])) [1 D.2834+0 S8 A64]) (unspec:DI [ (mem/v/f/c:DI (reg/f:DI 3 x3 [100]) [1 __stack_chk_guard+0 S8 A64]) ] UNSPEC_SP_SET)) (set (reg:DI 5 x5 [126]) (const_int 0 [0])) ]) stack-reorder.c:1 864 {stack_protect_set_di} (expr_list:REG_UNUSED (reg:DI 5 x5 [126]) (nil))) (insn:TI 16 8 71 (set (mem/j:QI (plus:DI (reg:DI 0 x0 [105]) (const_int 4016 [0xfb0])) [0 buf S1 A8]) (reg:QI 4 x4 [106])) stack-reorder.c:3 45 {*movqi_aarch64} (expr_list:REG_DEAD (reg:QI 4 x4 [106]) (expr_list:REG_DEAD (reg:DI 0 x0 [105]) (nil)))) (insn 71 16 22 (parallel [ (set (reg:DI 3 x3 [125]) (unspec:DI [ (mem/v/f/c:DI (plus:DI (reg/f:DI 29 x29) (const_int 88 [0x58])) [1 D.2834+0 S8 A64]) (mem/v/f/c:DI (reg/f:DI 3 x3 [100]) [1 __stack_chk_guard+0 S8 A64]) ] UNSPEC_SP_TEST)) (clobber (reg:DI 0 x0 [127])) ]) stack-reorder.c:14 866 {stack_protect_test_di} (expr_list:REG_UNUSED (reg:DI 0 x0 [127]) (nil))) (insn:TI 22 71 140 (set (mem/j:QI (plus:DI (reg:DI 1 x1 [110]) (const_int 4016 [0xfb0])) [0 buf S1 A8]) (reg:QI 2 x2 [ c ])) stack-reorder.c:4 45 {*movqi_aarch64} (expr_list:REG_DEAD (reg:QI 2 x2 [ c ]) (expr_list:REG_DEAD (reg:DI 1 x1 [110]) (nil))))