From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21307 invoked by alias); 15 Nov 2012 19:53:08 -0000 Received: (qmail 20613 invoked by uid 48); 15 Nov 2012 19:52:52 -0000 From: "eager at eagercon dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/55346] New: var-tracking generates incomplete/inaccurate debug info Date: Thu, 15 Nov 2012 19:53:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Keywords: X-Bugzilla-Severity: major X-Bugzilla-Who: eager at eagercon dot com 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 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: 2012-11/txt/msg01447.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55346 Bug #: 55346 Summary: var-tracking generates incomplete/inaccurate debug info Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: major Priority: P3 Component: rtl-optimization AssignedTo: unassigned@gcc.gnu.org ReportedBy: eager@eagercon.com Created attachment 28703 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28703 Test program Var-tracking is does not record the lifetime of variables allocated to registers correctly, resulting in gdb displaying the variable as "optimized out" when it is live. I've confirmed this problem on x86 and arm. The test case is a loop which parses command line options, indexed by integer variable argno. When compiled with "-g -O2", argno is allocated to rbx, which is never reused. The DWARF location list which is generated from NOTE_INSN_VAR_LOCATION insns, shows disjoint allocations for argno, omitting PC ranges where the variable is live in rbx. The DWARF location list has argno as literal 1 beyond the instruction where it is allocated to rbx. Argno is defined as rbx starts several instructions after it is allocated and ends premature. Var-tracking inserts a NOTE_INSN_VAR_LOCATION for argno as const int 1 at the start of the BB #2, but one is not inserted when argno is allocated to rbx later in BB #2. One is generated later, in BB #5. Var-tracking inserts a (nil) NOTE_INSN_VAR_LOCATION for argno after BB #3 (branch to epilogue), although argno is live and is used in BB #4, immediately following BB #3. Either this should not be generated or another NOTE_INSN_VAR_LOCATION for argno should be generated at the start of BB #4.