[DebugInfo] Fix: Variables that have no non-empty values being emitted when they...
authorStephen Tozer <Stephen.Tozer@Sony.com>
Tue, 20 Dec 2022 10:01:56 +0000 (10:01 +0000)
committerVitaly Buka <vitalybuka@google.com>
Sun, 25 Dec 2022 21:28:27 +0000 (13:28 -0800)
This patch fixes a simple bug where `DbgValueHistoryMap::hasNonEmptyLocation` was incorrectly handling DBG_VALUE_LIST instructions, treating empty values as non-empty, causing empty variables to be emitted into DWARF.

Reviewed By: Orlando

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

llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp
llvm/test/DebugInfo/X86/dbg_value_list_emission.mir

index 42715ef..2c90b9c 100644 (file)
@@ -264,7 +264,7 @@ bool DbgValueHistoryMap::hasNonEmptyLocation(const Entries &Entries) const {
     const MachineInstr *MI = Entry.getInstr();
     assert(MI->isDebugValue());
     // A DBG_VALUE $noreg is an empty variable location
-    if (MI->getOperand(0).isReg() && MI->getOperand(0).getReg() == 0)
+    if (MI->isUndefDebugValue())
       continue;
 
     return true;
index e447fa8..b965824 100644 (file)
@@ -93,9 +93,7 @@ body:             |
     \r
     ; (8) Check that a single $noreg location invalidates the entire entry.\r
     DBG_VALUE_LIST !30, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus, DW_OP_stack_value), $eax, $noreg, debug-location !15\r
-    ; CHECK:      DW_TAG_variable\r
-    ; CHECK-NEXT:   DW_AT_name ("localh")\r
-    ; CHECK-NOT:   DW_AT_location\r
+    ; CHECK-NOT:   DW_AT_name ("localh")\r
 \r
     RET64 debug-location !15\r
 ...\r