[DebugInfo][InstrRef] Track variable assignments in out-of-scope blocks
authorJeremy Morse <jeremy.morse@sony.com>
Thu, 25 Nov 2021 14:46:34 +0000 (14:46 +0000)
committerJeremy Morse <jeremy.morse@sony.com>
Thu, 25 Nov 2021 14:52:11 +0000 (14:52 +0000)
DBG_INSTR_REF's and  DBG_VALUE's can end up in blocks that aren't in the
lexical scope of their variable. It's arguable as to what we should do
about this, however VarLocBasedLDV permits such variable locations to be
propagated, so let's allow it in InstrRefBasedLDV.

It's necessary for the modified test to work.

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

llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
llvm/test/DebugInfo/X86/stack-value-dwarf2.ll

index 6d19c23..eff8ec7 100644 (file)
@@ -2487,11 +2487,10 @@ void InstrRefBasedLDV::buildVLocValueMap(const DILocation *DILoc,
   // "blocks that are potentially in scope. See comment at start of vlocJoin.
   SmallPtrSet<const MachineBasicBlock *, 8> InScopeBlocks = BlocksToExplore;
 
-  // Old LiveDebugValues tracks variable locations that come out of blocks
-  // not in scope, where DBG_VALUEs occur. This is something we could
-  // legitimately ignore, but lets allow it for now.
-  if (EmulateOldLDV)
-    BlocksToExplore.insert(AssignBlocks.begin(), AssignBlocks.end());
+  // VarLoc LiveDebugValues tracks variable locations that are defined in
+  // blocks not in scope. This is something we could legitimately ignore, but
+  // lets allow it for now for the sake of coverage.
+  BlocksToExplore.insert(AssignBlocks.begin(), AssignBlocks.end());
 
   // We also need to propagate variable values through any artificial blocks
   // that immediately follow blocks in scope.
index 0db70b9..094dd94 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc -filetype=obj -o - %s -experimental-debug-variable-locations=false | llvm-dwarfdump -debug-loc - | FileCheck %s
+; RUN: llc -filetype=obj -o - %s -experimental-debug-variable-locations=true | llvm-dwarfdump -debug-loc - | FileCheck %s
 
 ; Note that it would be even better to avoid emitting the empty piece.
 ; CHECK:  {{.*}}: DW_OP_piece 0x8{{$}}