https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61801
Bug ID: 61801 Summary: sched2 miscompiles syscall sequence with -g Product: gcc Version: 4.8.3 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: rguenth at gcc dot gnu.org Target: i?86-*-* Created attachment 33118 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33118&action=edit testcase from glibc trunk gcc-4.8 -S bug-887141_pthread_create.i -m32 -std=gnu99 -fgnu89-inline -O2 -fmerge-all-constants -frounding-math -fPIC -mpreferred-stack-boundary=4 -fverbose-asm -da -fdump-tree-all -g sched2 moves the load from 20(%esp) up across the spill. __nptl_setxid: ... .LBB347: .loc 1 1174 0 movl 80(%esp), %eax # cmdp, tmp189 movl 20(%esp), %esi # %sfp, result <---- bogus location .LVL184: movl (%eax), %eax # cmdp_33(D)->syscall_no, cmdp_33(D)->syscall_no movl %eax, 20(%esp) # cmdp_33(D)->syscall_no, %sfp .LVL185: movl 80(%esp), %eax # cmdp, tmp191 movl 4(%eax), %edi # cmdp_33(D)->id, cmdp_33(D)->id movl 8(%eax), %ecx # cmdp_33(D)->id, cmdp_33(D)->id movl 12(%eax), %edx # cmdp_33(D)->id, cmdp_33(D)->id <---- moved from here movl %esi, %eax # result, result #APP # 1174 "allocatestack.c" 1 xchgl %ebx, %edi int $0x80 xchgl %edi, %ebx before sched2 everything looks ok (apart from odd debug-insn with asm): (code_label 308 344 309 40 194 "" [1 uses]) (note 309 308 531 40 [bb 40] NOTE_INSN_BASIC_BLOCK) (insn 531 309 310 40 (set (reg:SI 0 ax [189]) (mem/f/c:SI (plus:SI (reg/f:SI 7 sp) (const_int 80 [0x50])) [4 cmdp+0 S4 A32])) allocatestack.c:1174 89 {*movsi_internal} (nil)) (insn 310 531 532 40 (set (reg:SI 0 ax [orig:137 cmdp_33(D)->syscall_no ] [137]) (mem:SI (reg:SI 0 ax [189]) [2 cmdp_33(D)->syscall_no+0 S4 A32])) allocatestack.c:1174 89 {*movsi_internal} (nil)) (insn 532 310 533 40 (set (mem/c:SI (plus:SI (reg/f:SI 7 sp) (const_int 20 [0x14])) [54 %sfp+-12 S4 A32]) (reg:SI 0 ax [orig:137 cmdp_33(D)->syscall_no ] [137])) allocatestack.c:1174 89 {*movsi_internal} (expr_list:REG_DEAD (reg:SI 0 ax [orig:137 cmdp_33(D)->syscall_no ] [137]) (nil))) (insn 533 532 311 40 (set (reg:SI 0 ax [191]) (mem/f/c:SI (plus:SI (reg/f:SI 7 sp) (const_int 80 [0x50])) [4 cmdp+0 S4 A32])) allocatestack.c:1174 89 {*movsi_internal} (nil)) (insn 311 533 312 40 (set (reg:SI 5 di [orig:138 cmdp_33(D)->id ] [138]) (mem:SI (plus:SI (reg:SI 0 ax [191]) (const_int 4 [0x4])) [5 cmdp_33(D)->id+0 S4 A32])) allocatestack.c:1174 89 {*movsi_internal} (nil)) (insn 312 311 313 40 (set (reg:SI 2 cx [orig:139 cmdp_33(D)->id+4 ] [139]) (mem:SI (plus:SI (reg:SI 0 ax [192]) (const_int 8 [0x8])) [5 cmdp_33(D)->id+4 S4 A32])) allocatestack.c:1174 89 {*movsi_internal} (nil)) (insn 313 312 314 40 (set (reg:SI 1 dx [orig:140 cmdp_33(D)->id+8 ] [140]) (mem:SI (plus:SI (reg:SI 0 ax [193]) (const_int 12 [0xc])) [5 cmdp_33(D)->id+8 S4 A32])) allocatestack.c:1174 89 {*movsi_internal} (expr_list:REG_DEAD (reg:SI 0 ax [193]) (nil))) (note 314 313 316 40 NOTE_INSN_DELETED) (debug_insn 316 314 477 40 (var_location:SI resultvar (asm_operands/v:SI ("xchgl %%ebx, %%edi int $0x80 xchgl %%edi, %%ebx ") ("=a") 0 [ (mem/c:SI (plus:SI (reg/f:SI 7 sp) (const_int 20 [0x14])) [54 %sfp+-12 S4 A32]) (reg:SI 5 di [orig:138 cmdp_33(D)->id ] [138]) (reg:SI 2 cx [orig:139 cmdp_33(D)->id+4 ] [139]) (reg:SI 1 dx [orig:140 cmdp_33(D)->id+8 ] [140]) ] [ (asm_input:SI ("0") (null):0) (asm_input:SI ("D") (null):0) (asm_input:SI ("c") (null):0) (asm_input:SI ("d") (null):0) ] [] allocatestack.c:1174)) allocatestack.c:1174 -1 (nil)) (insn 477 316 536 40 (set (reg/v:SI 4 si [orig:60 result ] [60]) (mem/c:SI (plus:SI (reg/f:SI 7 sp) (const_int 20 [0x14])) [54 %sfp+-12 S4 A32])) allocatestack.c:1174 89 {*movsi_internal} (nil)) (insn 536 477 317 40 (set (reg/v:SI 0 ax [orig:60 result ] [60]) (reg/v:SI 4 si [orig:60 result ] [60])) allocatestack.c:1174 89 {*movsi_internal} (expr_list:REG_DEAD (reg/v:SI 4 si [orig:60 result ] [60]) (nil))) (insn 317 536 537 40 (parallel [ (set (reg/v:SI 0 ax [orig:60 result ] [60]) (asm_operands/v:SI ("xchgl %%ebx, %%edi int $0x80 xchgl %%edi, %%ebx