[PATCH] D11933: Extend debug ranges and provide multiple location support for debug variables

Vikram TV via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 11 03:21:43 PDT 2015


tvvikram created this revision.
tvvikram added a subscriber: llvm-commits.


This patch is an early implementation to extend debug ranges and provide multiple location support for debug variables. This work is based on the idea put forward in the mail thread: http://lists.cs.uiuc.edu/pipermail/llvmdev/2015-June/087109.html

**A. Debug Range Extension:** Currently, the debug ranges in LLVM end prematurely at the end of every basic block. This patch tries to extend them across basic blocks such that when two predecessors of a basic block have the same variable residing in the same location, a new debug value representing the variable and the location is added at the start of the current basic block.

Example: Consider the following partial code containing only DBG_VALUE instructions:
BB#3:
.
DBG_VALUE %EBX, %noreg, !"n", <!17>; line no:8
.
JMP_1 <BB#5>

BB#4:
.
DBG_VALUE %EBX, %noreg, !"n", <!17>; line no:8
.

BB#5: ; preds - BB#3, BB#4
DBG_VALUE %EBX, %noreg, !"n", <!17>; line no:8 <-- newly inserted
.

Here, BB#5 is a successor of both BB#3 and BB#4. Source variable "n" resides in %EBX on both paths. So a new DBG_VALUE instruction will be added at the start of BB#5 for "n" at location %EBX.

**B. Multiple locations:** LLVM currently can represent a debug variable only at a single location. This patch provides an infrastructure for earlier passes to express multiple locations for a debug variable by adding a new flag - PreserveDbgValLoc to the DBG_VALUE instruction. The presence of the flag will mean multiple debug ranges for the variable can co-exist together. The patch also infers multiple locations by looking at move instructions.
  Example - inferring from move instruction: Consider the following two instructions:
     DBG_VALUE %EDI, %noreg, !"n", <!12>
     %EBX<def> = MOV32rr %EDI
     DBG_VALUE %EBX, %noreg, !"n", <!12>; flags: PreserveDbgValLoc  <-- newly inserted
After the copy instruction, the value ā€œnā€ will be present in two locations - %EDI and %EBX and the same is represented with the new DBG_VALUE instruction having the flag PreserveDbgValLoc set.

The two ranges continue to exist together until one of the following happens:
Either %EDI or %EBX is clobbered, the two ranges are conservatively ended
A DBG_VALUE instruction for variable ā€œnā€ without the flag is seen, when the previous ranges are ended.

Test cases: 3 new test cases are added to test the above implementations. There are numerous places in the test cases where debug range extension and addition of PreserveDbgValLoc happens. All test cases under 'ninja check' run, with around 5 miscompare errors. I will correct them once the implementation is okay as the miscompares are volatile with code change.

SVN base revision used: 243841

http://reviews.llvm.org/D11933

Files:
  include/llvm/CodeGen/MachineInstr.h
  include/llvm/CodeGen/Passes.h
  include/llvm/InitializePasses.h
  include/llvm/Target/TargetInstrInfo.h
  lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp
  lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.h
  lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  lib/CodeGen/CMakeLists.txt
  lib/CodeGen/CodeGen.cpp
  lib/CodeGen/DebugValueFixup.cpp
  lib/CodeGen/MachineInstr.cpp
  lib/CodeGen/Passes.cpp
  lib/Target/X86/X86InstrInfo.cpp
  lib/Target/X86/X86InstrInfo.h
  test/DebugInfo/X86/array.ll
  test/DebugInfo/X86/fission-ranges.ll
  test/DebugInfo/X86/sret.ll
  test/DebugInfo/extend-debug-range.ll
  test/DebugInfo/multiple-locations-1.ll
  test/DebugInfo/multiple-locations-2.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11933.31781.patch
Type: text/x-patch
Size: 55508 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150811/3263facf/attachment.bin>


More information about the llvm-commits mailing list