Index: llvm/trunk/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.h =================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.h +++ llvm/trunk/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.h @@ -52,6 +52,10 @@ 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, Index: llvm/trunk/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp =================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp +++ llvm/trunk/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp @@ -269,3 +269,33 @@ } } } + +#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() << ""; + + dbgs() << " --\n"; + + for (const InstrRange &Range : Ranges) { + dbgs() << " Begin: " << *Range.first; + if (Range.second) + dbgs() << " End : " << *Range.second; + dbgs() << "\n"; + } + } +} +#endif Index: llvm/trunk/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp =================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp +++ llvm/trunk/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp @@ -25,6 +25,8 @@ using namespace llvm; +#define DEBUG_TYPE "dwarfdebug" + Optional DbgVariableLocation::extractFromMachineInstruction( const MachineInstr &Instruction) { @@ -190,6 +192,7 @@ 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) { Index: llvm/trunk/test/DebugInfo/X86/dump-dbg-value-hist-calc.ll =================================================================== --- llvm/trunk/test/DebugInfo/X86/dump-dbg-value-hist-calc.ll +++ llvm/trunk/test/DebugInfo/X86/dump-dbg-value-hist-calc.ll @@ -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 -- +; 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)