public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/61801] New: sched2 miscompiles syscall sequence with -g
Date: Mon, 14 Jul 2014 14:46:00 -0000	[thread overview]
Message-ID: <bug-61801-4@http.gcc.gnu.org/bugzilla/> (raw)

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


             reply	other threads:[~2014-07-14 14:46 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-14 14:46 rguenth at gcc dot gnu.org [this message]
2014-07-15  9:35 ` [Bug rtl-optimization/61801] " rguenth at gcc dot gnu.org
2014-07-15  9:42 ` rguenth at gcc dot gnu.org
2014-07-15  9:47 ` rguenth at gcc dot gnu.org
2014-07-15 10:40 ` rguenth at gcc dot gnu.org
2014-07-15 14:37 ` rguenth at gcc dot gnu.org
2014-07-15 18:59 ` jakub at gcc dot gnu.org
2014-07-16  8:29 ` rguenth at gcc dot gnu.org
2014-07-16  9:03 ` rguenth at gcc dot gnu.org
2014-07-17  7:48 ` rguenth at gcc dot gnu.org
2014-07-17  7:49 ` rguenth at gcc dot gnu.org
2014-07-17  7:50 ` rguenth at gcc dot gnu.org
2014-07-17  7:50 ` rguenth at gcc dot gnu.org
2014-07-25  9:33 ` rguenth at gcc dot gnu.org
2014-07-26 14:44 ` trippels at gcc dot gnu.org
2014-07-28  7:54 ` rguenth at gcc dot gnu.org
2014-07-28  7:55 ` rguenth at gcc dot gnu.org
2014-07-28  7:59 ` rguenth at gcc dot gnu.org
2014-07-28  9:02 ` rguenth at gcc dot gnu.org
2014-07-28  9:02 ` rguenth at gcc dot gnu.org
2014-07-28  9:03 ` rguenth at gcc dot gnu.org
2014-08-06  8:41 ` jakub at gcc dot gnu.org
2014-08-06  8:44 ` jakub at gcc dot gnu.org
2014-08-06  8:50 ` jakub at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-61801-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).