[llvm] r363245 - [DebugInfo] Use FrameDestroy to extend stack locations to end-of-function

Jeremy Morse via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 13 03:03:17 PDT 2019


Author: jmorse
Date: Thu Jun 13 03:03:17 2019
New Revision: 363245

URL: http://llvm.org/viewvc/llvm-project?rev=363245&view=rev
Log:
[DebugInfo] Use FrameDestroy to extend stack locations to end-of-function

We aim to ignore changes in variable locations during the prologue and
epilogue of functions, to avoid using space documenting location changes
that aren't visible. However in D61940 / r362951 this got ripped out as
the previous implementation was unsound.

Instead, use the FrameDestroy flag to identify when we're in the epilogue
of a function, and ignore variable location changes accordingly. This fits
in with existing code that examines the FrameSetup flag.

Some variable locations get shuffled in modified tests as they now cover
greater ranges, which is what would be expected. Some additional
single-location variables are generated too. Two tests are un-xfailed,
they were only xfailed due to r362951 deleting functionality they depended
on.

Apparently some out-of-tree backends don't accurately maintain FrameDestroy
flags -- if you're an out-of-tree maintainer and see changes in variable
locations disappear due to a faulty FrameDestroy flag, it's safe to back
this change out. The impact is just slightly more debug info than necessary.

Differential Revision: https://reviews.llvm.org/D62314

Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp
    llvm/trunk/test/DebugInfo/COFF/pieces.ll
    llvm/trunk/test/DebugInfo/X86/dbg-addr.ll
    llvm/trunk/test/DebugInfo/X86/debug-loc-offset.mir
    llvm/trunk/test/DebugInfo/X86/pr19307.mir

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp?rev=363245&r1=363244&r2=363245&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp Thu Jun 13 03:03:17 2019
@@ -275,9 +275,12 @@ void llvm::calculateDbgEntityHistory(con
             clobberRegisterUses(RegVars, MO.getReg(), DbgValues, LiveEntries,
                                 MI);
           // If this is a register def operand, it may end a debug value
-          // range. Ignore defs of the frame register in the prologue.
+          // range. Ignore frame-register defs in the epilogue and prologue,
+          // we expect debuggers to understand that stack-locations are
+          // invalid outside of the function body.
           else if (MO.getReg() != FrameReg ||
-                   !MI.getFlag(MachineInstr::FrameSetup)) {
+                   (!MI.getFlag(MachineInstr::FrameDestroy) &&
+                   !MI.getFlag(MachineInstr::FrameSetup))) {
             for (MCRegAliasIterator AI(MO.getReg(), TRI, true); AI.isValid();
                  ++AI)
               clobberRegisterUses(RegVars, *AI, DbgValues, LiveEntries, MI);

Modified: llvm/trunk/test/DebugInfo/COFF/pieces.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/pieces.ll?rev=363245&r1=363244&r2=363245&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/pieces.ll (original)
+++ llvm/trunk/test/DebugInfo/COFF/pieces.ll Thu Jun 13 03:03:17 2019
@@ -104,8 +104,9 @@
 ; ASM:         #APP
 ; ASM:         #NO_APP
 ; ASM:         movl    [[offset_o_x]](%rsp), %eax          # 4-byte Reload
-; ASM: [[spill_o_x_end:\.Ltmp[0-9]+]]:
 ; ASM:         retq
+; ASM-NEXT: [[spill_o_x_end:\.Ltmp[0-9]+]]:
+; ASM-NEXT: .Lfunc_end4:
 
 
 ; ASM-LABEL:  .short  4423                    # Record kind: S_GPROC32_ID
@@ -231,7 +232,7 @@
 ; ASM:        .asciz  "bitpiece_spill"        # Function name
 ; ASM:        .short  4414                    # Record kind: S_LOCAL
 ; ASM:        .asciz  "o"
-; ASM:        .cv_def_range    [[spill_o_x_start]] [[spill_o_x_end]], "E\021O\001A\000$\000\000\000"
+; ASM:        .cv_def_range    [[spill_o_x_start]] .Lfunc_end4, "E\021O\001A\000$\000\000\000"
 
 ; OBJ-LABEL: GlobalProcIdSym {
 ; OBJ:         Kind: S_GPROC32_ID (0x1147)

Modified: llvm/trunk/test/DebugInfo/X86/dbg-addr.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/dbg-addr.ll?rev=363245&r1=363244&r2=363245&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/dbg-addr.ll (original)
+++ llvm/trunk/test/DebugInfo/X86/dbg-addr.ll Thu Jun 13 03:03:17 2019
@@ -9,12 +9,8 @@
 ; CHECK-LABEL: use_dbg_addr:
 ; CHECK: #DEBUG_VALUE: use_dbg_addr:o <- [$rsp+0]
 
-; FIXME: Avoid the use of a single-location location list and use
-; DW_AT_start_offset instead.
-
 ; DWARF: DW_TAG_variable
-; DWARF-NEXT:              DW_AT_location (0x00000000
-; DWARF-NEXT:                          [0x{{.*}}, 0x{{.*}}): DW_OP_breg7 RSP+0)
+; DWARF-NEXT:              DW_AT_location (DW_OP_fbreg +0)
 ; DWARF-NEXT:              DW_AT_name ("o")
 
 

Modified: llvm/trunk/test/DebugInfo/X86/debug-loc-offset.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/debug-loc-offset.mir?rev=363245&r1=363244&r2=363245&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/debug-loc-offset.mir (original)
+++ llvm/trunk/test/DebugInfo/X86/debug-loc-offset.mir Thu Jun 13 03:03:17 2019
@@ -1,11 +1,5 @@
 # RUN: llc -o - %s -start-after=patchable-function -filetype=obj -O0 -mtriple=i386-unknown-linux-gnu -dwarf-version=4 | llvm-dwarfdump -v - | FileCheck %s
 
-# XFAIL: *
-# Marked XFail due to the removal of "ChangingRegs" from
-# DbgEntityHistoryCalculator, shortening the checked range to not reach the
-# end of the function. Fixed by an about-to-land patch using the FrameDestroy
-# flag to identify the end of functions.
-
 # From the code:
 #
 # debug-loc-offset1.cc

Modified: llvm/trunk/test/DebugInfo/X86/pr19307.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/pr19307.mir?rev=363245&r1=363244&r2=363245&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/pr19307.mir (original)
+++ llvm/trunk/test/DebugInfo/X86/pr19307.mir Thu Jun 13 03:03:17 2019
@@ -1,11 +1,5 @@
 # RUN: llc -o - %s -start-after=patchable-function -O0 | FileCheck %s
 
-# XFAIL: *
-# Marked XFail due to the removal of "ChangingRegs" from
-# DbgEntityHistoryCalculator, shortening the checked range to not reach the
-# end of the function. Fixed by an about-to-land patch using the FrameDestroy
-# flag to identify the end of functions.
-
 # Generated from the source file pr19307.cc:
 # #include <string>
 # void parse_range(unsigned long long &offset, unsigned long long &limit,




More information about the llvm-commits mailing list