From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16215 invoked by alias); 15 Jul 2014 14:37:09 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 16150 invoked by uid 48); 15 Jul 2014 14:37:05 -0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/61801] sched2 miscompiles syscall sequence with -g Date: Tue, 15 Jul 2014 14:37:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 4.8.3 X-Bugzilla-Keywords: missed-optimization, ra, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-07/txt/msg00973.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61801 --- Comment #5 from Richard Biener --- ;; --- Region Dependences --- b 12 bb 0 ;; insn code bb dep prio cost reservation ;; ---- ---- -- --- ---- ---- ----------- ... ;; 239 90 12 1 5 1 athlon-direct,athlon-agu,athlon-store : 127 123n 122nm 240 ... ;; 122 -1 12 7 0 0 nothing : 124 123nm 243 216m ;; 216 90 12 0 5 3 athlon-direct,athlon-load : 127 123nm 243 ... which maps to: (insn 239 116 240 12 (set (mem/c:SI (reg/f:SI 7 sp) [11 %sfp+-16 S4 A32]) (reg:SI 0 ax [orig:127 cmdp_14(D)->syscall_no ] [127])) bug-887141_pthread_create.1.min.i:77 90 {*movsi_internal} (expr_list:REG_DEAD (reg:SI 0 ax [orig:127 cmdp_14(D)->syscall_no ] [127]) (nil))) ... (debug_insn 122 120 216 12 (var_location:SI resultvar (asm_operands/v:SI ("xchgl %%ebx, %%edi int $0x80 xchgl %%edi, %%ebx ") ("=a") 0 [ (mem/c:SI (reg/f:SI 7 sp) [11 %sfp+-16 S4 A32]) (reg:SI 5 di [orig:128 cmdp_14(D)->id ] [128]) (reg:SI 2 cx [orig:129 cmdp_14(D)->id+4 ] [129]) (reg:SI 1 dx [orig:130 cmdp_14(D)->id+8 ] [130]) ] [ (asm_input:SI ("0") bug-887141_pthread_create.1.min.i:77) (asm_input:SI ("D") bug-887141_pthread_create.1.min.i:77) (asm_input:SI ("c") bug-887141_pthread_create.1.min.i:77) (asm_input:SI ("d") bug-887141_pthread_create.1.min.i:77) ] [] bug-887141_pthread_create.1.min.i:77)) bug-887141_pthread_create.1.min.i:77 -1 (nil)) (insn 216 122 243 12 (set (reg/v:SI 4 si [orig:84 result ] [84]) (mem/c:SI (reg/f:SI 7 sp) [11 %sfp+-16 S4 A32])) bug-887141_pthread_create.1.min.i:77 90 {*movsi_internal} (nil)) insn 123 is the real asm. Not sure if the dependence of 239 via 122 to 216 is supposed to prevent scheduling 216 before 239. If so, then dependence information is correct. The only forward dependence to 216 is really from the debug insn. But then: ;; dependencies resolved: insn 238 ;; tick updated: insn 238 into ready ;; dependencies resolved: insn 216 ;; tick updated: insn 216 into ready ;; Advanced a state. ;; Ready list after queue_to_ready: 216:67:prio=5 238:59:prio=11 what? 216 is already ready? ;; Ready list (t = 0): 216:67:prio=5 238:59:prio=11 ;; 0--> b 0: i 238 ax=[sp+0x30] :athlon-direct,athlon-load ;; dependencies resolved: insn 116 ;; Ready-->Q: insn 116: queued for 3 cycles (change queue index). ;; tick updated: insn 116 into queue with cost=3 ;; Ready list after ready_sort: 216:67:prio=5 ;; Ready list (t = 0): 216:67:prio=5 ;; 0--> b 0: i 216 si=[sp] :athlon-direct,athlon-load ;; resetting: debug insn 122 yeah, so we reset the debug insn. But ignored the indirect dependence from 239. Now, of course I'm lost in the scheduler code, not knowing how it is intended to work with debug-insns. As a band-aid fix I'd simply never generate debug_insns with asms ...