From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20844 invoked by alias); 30 Nov 2010 14:29:54 -0000 Received: (qmail 20833 invoked by uid 22791); 30 Nov 2010 14:29:54 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 30 Nov 2010 14:29:49 +0000 From: "krebbel at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug debug/46724] New: Wrong debug info: Invalid variable location X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: debug X-Bugzilla-Keywords: X-Bugzilla-Severity: major X-Bugzilla-Who: krebbel 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-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Tue, 30 Nov 2010 14:33:00 -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 X-SW-Source: 2010-11/txt/msg03678.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46724 Summary: Wrong debug info: Invalid variable location Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: major Priority: P3 Component: debug AssignedTo: unassigned@gcc.gnu.org ReportedBy: krebbel@gcc.gnu.org The guality/nrv-1.c testcase currently fails on s390x when compiled with -O2: Breakpoint 1, f () at /build3/gcc-head/gcc/testsuite/gcc.dg/guality/nrv-1.c:20 20 a2.i[4] = 7; /* { dg-final { gdb-test 20 "a2.i\[0\]" "42" } } */ Missing separate debuginfos, use: debuginfo-install glibc-2.12.1-2.s390x (gdb) p a2.i[0] $1 = -336596880 The memory location of 'a2' is given as being based on r1: readelf --debug-dump=info ... <2><85>: Abbrev Number: 9 (DW_TAG_variable) <86> DW_AT_name : a2 <89> DW_AT_decl_file : 1 <8a> DW_AT_decl_line : 16 <8b> DW_AT_type : <0x2d> <8f> DW_AT_location : 2 byte block: 71 0 (DW_OP_breg1: 0) ... But in fact r1 is not used at all. Instead the location is in r2: f: .LFB0: .file 1 "/build3/gcc-head/gcc/testsuite/gcc.dg/guality/nrv-1.c" .loc 1 15 0 .cfi_startproc .loc 1 17 0 lhi %r3,42 st %r3,0(%r2) <-- a2.i[0] = 42; ... a2 is returned by f. The address of the location where the return value should reside is passed to f as implicit first parameter in r2. Right before cprop_hardreg the code looks like this. r2 is copied into r1 and r1 is used to reference a2. DECL_RTL () is (mem/s:SI (reg/f:DI 1 %r1 [orig:45 D.1986 ] [45]). nrv-1.c.201r.ce3: (insn 2 8 47 2 (set (reg/f:DI 1 %r1 [orig:45 D.1986 ] [45]) (reg:DI 2 %r2 [ D.1986 ])) /build3/gcc-head/gcc/testsuite/gcc.dg/guality/nrv-1.c:15 62 {*movdi_64} (nil)) (insn 47 2 6 2 (set (reg:SI 3 %r3) (const_int 42 [0x2a])) /build3/gcc-head/gcc/testsuite/gcc.dg/guality/nrv-1.c:17 66 {*movsi_zarch} (nil)) (insn 6 47 45 2 (set (mem/s:SI (reg/f:DI 1 %r1 [orig:45 D.1986 ] [45]) [2 .i+0 S4 A32]) (reg:SI 3 %r3)) /build3/gcc-head/gcc/testsuite/gcc.dg/guality/nrv-1.c:17 66 {*movsi_zarch} (expr_list:REG_DEAD (reg:SI 3 %r3) (nil))) Then r1 is propagated into insn 6 and insn 2 is removed in DCE while DECL_RTL () still references r1. nrv-1.c.203r.cprop_hardreg: (insn 2 8 47 2 (set (reg/f:DI 1 %r1 [orig:45 D.1986 ] [45]) (reg:DI 2 %r2 [ D.1986 ])) /build3/gcc-head/gcc/testsuite/gcc.dg/guality/nrv-1.c:15 62 {*movdi_64} (nil)) (insn 47 2 6 2 (set (reg:SI 3 %r3) (const_int 42 [0x2a])) /build3/gcc-head/gcc/testsuite/gcc.dg/guality/nrv-1.c:17 66 {*movsi_zarch} (nil)) (insn 6 47 45 2 (set (mem/s:SI (reg/f:DI 2 %r2 [orig:45 D.1986 ] [45]) [2 .i+0 S4 A32]) (reg:SI 3 %r3)) /build3/gcc-head/gcc/testsuite/gcc.dg/guality/nrv-1.c:17 66 {*movsi_zarch} (expr_list:REG_DEAD (reg:SI 3 %r3) (nil))) When generating the debug info for a2 add_location_or_const_value_attribute first tries to find an RTX for a2 directly by invoking rtl_for_decl_location p on the VAR_DECL of a2 what returns NULL. It then invokes loc_list_from_tree which uses the DECL_VALUE_EXPR of the a2 decl - this is . rtl_for_decl_location then returns (mem/s:SI (reg/f:DI 1 %r1 [orig:45 D.1986 ] [45]) for .