diff --git a/llvm/include/llvm/CodeGen/DbgEntityHistoryCalculator.h b/llvm/include/llvm/CodeGen/DbgEntityHistoryCalculator.h --- a/llvm/include/llvm/CodeGen/DbgEntityHistoryCalculator.h +++ b/llvm/include/llvm/CodeGen/DbgEntityHistoryCalculator.h @@ -122,7 +122,7 @@ EntriesMap::const_iterator end() const { return VarEntries.end(); } #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) - LLVM_DUMP_METHOD void dump() const; + LLVM_DUMP_METHOD void dump(StringRef FuncName) const; #endif }; diff --git a/llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp b/llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp --- a/llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp @@ -138,6 +138,9 @@ // references if any entries are removed. SmallVector Offsets; + LLVM_DEBUG(dbgs() << "Trimming location ranges for function '" << MF.getName() + << "'\n"); + for (auto &Record : VarEntries) { auto &HistoryMapEntries = Record.second; if (HistoryMapEntries.empty()) @@ -213,6 +216,8 @@ // count of the closing entry, if one exists. if (EndIndex != NoEntry) ReferenceCount[EndIndex] -= 1; + LLVM_DEBUG(dbgs() << "Dropping value outside scope range of variable: "; + StartMI->print(llvm::dbgs());); } } @@ -253,6 +258,8 @@ // ToRemove indices are valid after each erase. for (EntryIndex Idx : llvm::reverse(ToRemove)) HistoryMapEntries.erase(HistoryMapEntries.begin() + Idx); + LLVM_DEBUG(llvm::dbgs() << "New HistoryMap('" << LocalVar->getName() + << "') size: " << HistoryMapEntries.size() << "\n"); } } @@ -555,8 +562,8 @@ } #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) -LLVM_DUMP_METHOD void DbgValueHistoryMap::dump() const { - dbgs() << "DbgValueHistoryMap:\n"; +LLVM_DUMP_METHOD void DbgValueHistoryMap::dump(StringRef FuncName) const { + dbgs() << "DbgValueHistoryMap('" << FuncName << "'):\n"; for (const auto &VarRangePair : *this) { const InlinedEntity &Var = VarRangePair.first; const Entries &Entries = VarRangePair.second; diff --git a/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp b/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp --- a/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp @@ -273,7 +273,7 @@ InstOrdering.initialize(*MF); if (TrimVarLocs) DbgValues.trimLocationRanges(*MF, LScopes, InstOrdering); - LLVM_DEBUG(DbgValues.dump()); + LLVM_DEBUG(DbgValues.dump(MF->getName())); // Request labels for the full history. for (const auto &I : DbgValues) {