[llvm] r333801 - Add a debug dump for DbgValueHistoryMap
Vedant Kumar via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 1 15:33:15 PDT 2018
Author: vedantk
Date: Fri Jun 1 15:33:15 2018
New Revision: 333801
URL: http://llvm.org/viewvc/llvm-project?rev=333801&view=rev
Log:
Add a debug dump for DbgValueHistoryMap
This makes it easier to inspect the results of
DbgValueHistoryCalculator.
Differential Revision: https://reviews.llvm.org/D47663
Added:
llvm/trunk/test/DebugInfo/X86/dump-dbg-value-hist-calc.ll
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.h
llvm/trunk/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp?rev=333801&r1=333800&r2=333801&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp Fri Jun 1 15:33:15 2018
@@ -269,3 +269,33 @@ void llvm::calculateDbgValueHistory(cons
}
}
}
+
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
+LLVM_DUMP_METHOD void DbgValueHistoryMap::dump() const {
+ dbgs() << "DbgValueHistoryMap:\n";
+ for (const auto &VarRangePair : *this) {
+ const InlinedVariable &Var = VarRangePair.first;
+ const InstrRanges &Ranges = VarRangePair.second;
+
+ const DILocalVariable *LocalVar = Var.first;
+ const DILocation *Location = Var.second;
+
+ dbgs() << " - " << LocalVar->getName() << " at ";
+
+ if (Location)
+ dbgs() << Location->getFilename() << ":" << Location->getLine() << ":"
+ << Location->getColumn();
+ else
+ dbgs() << "<unknown location>";
+
+ dbgs() << " --\n";
+
+ for (const InstrRange &Range : Ranges) {
+ dbgs() << " Begin: " << *Range.first;
+ if (Range.second)
+ dbgs() << " End : " << *Range.second;
+ dbgs() << "\n";
+ }
+ }
+}
+#endif
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.h?rev=333801&r1=333800&r2=333801&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.h Fri Jun 1 15:33:15 2018
@@ -52,6 +52,10 @@ public:
void clear() { VarInstrRanges.clear(); }
InstrRangesMap::const_iterator begin() const { return VarInstrRanges.begin(); }
InstrRangesMap::const_iterator end() const { return VarInstrRanges.end(); }
+
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
+ LLVM_DUMP_METHOD void dump() const;
+#endif
};
void calculateDbgValueHistory(const MachineFunction *MF,
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp?rev=333801&r1=333800&r2=333801&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp Fri Jun 1 15:33:15 2018
@@ -25,6 +25,8 @@
using namespace llvm;
+#define DEBUG_TYPE "dwarfdebug"
+
Optional<DbgVariableLocation>
DbgVariableLocation::extractFromMachineInstruction(
const MachineInstr &Instruction) {
@@ -190,6 +192,7 @@ void DebugHandlerBase::beginFunction(con
assert(DbgValues.empty() && "DbgValues map wasn't cleaned!");
calculateDbgValueHistory(MF, Asm->MF->getSubtarget().getRegisterInfo(),
DbgValues);
+ LLVM_DEBUG(DbgValues.dump());
// Request labels for the full history.
for (const auto &I : DbgValues) {
Added: llvm/trunk/test/DebugInfo/X86/dump-dbg-value-hist-calc.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/dump-dbg-value-hist-calc.ll?rev=333801&view=auto
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/dump-dbg-value-hist-calc.ll (added)
+++ llvm/trunk/test/DebugInfo/X86/dump-dbg-value-hist-calc.ll Fri Jun 1 15:33:15 2018
@@ -0,0 +1,21 @@
+; REQUIRES: asserts
+; RUN: opt -S -o - -debugify %s \
+; RUN: | %llc_dwarf -debug-only=dwarfdebug -o /dev/null 2>&1 \
+; RUN: | FileCheck %s
+
+target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-apple-macosx"
+
+; CHECK: DbgValueHistoryMap:
+; CHECK-NEXT: - 1 at <unknown location> --
+; CHECK-NEXT: Begin: DBG_VALUE {{.*}} line no:1
+; CHECK-NEXT: End : CALL64pcrel32 @h{{.*}}:2:1
+
+define void @f() {
+entry:
+ %a = add i32 0, 0
+ %b = call i32 @h(i32 %a)
+ ret void
+}
+
+declare i32 @h(i32)
More information about the llvm-commits
mailing list