Index: llvm/trunk/include/llvm/CodeGen/DbgEntityHistoryCalculator.h =================================================================== --- llvm/trunk/include/llvm/CodeGen/DbgEntityHistoryCalculator.h +++ llvm/trunk/include/llvm/CodeGen/DbgEntityHistoryCalculator.h @@ -32,39 +32,39 @@ /// End is not specified, the location is valid until the first overlapping /// DBG_VALUE if any such DBG_VALUE exists, otherwise it is valid until the /// end of the function. - class InstrRange { + class Entry { const MachineInstr *Begin; const MachineInstr *End; public: - InstrRange(const MachineInstr *Begin) : Begin(Begin), End(nullptr) {} + Entry(const MachineInstr *Begin) : Begin(Begin), End(nullptr) {} const MachineInstr *getBegin() const { return Begin; } const MachineInstr *getEnd() const { return End; } bool isClosed() const { return End; } - void endRange(const MachineInstr &End); + void endEntry(const MachineInstr &End); }; - using InstrRanges = SmallVector; + using Entries = SmallVector; using InlinedEntity = std::pair; - using InstrRangesMap = MapVector; + using EntriesMap = MapVector; private: - InstrRangesMap VarInstrRanges; + EntriesMap VarEntries; public: - void startInstrRange(InlinedEntity Var, const MachineInstr &MI); - void endInstrRange(InlinedEntity Var, const MachineInstr &MI); + void startEntry(InlinedEntity Var, const MachineInstr &MI); + void endEntry(InlinedEntity Var, const MachineInstr &MI); // Returns register currently describing @Var. If @Var is currently // unaccessible or is not described by a register, returns 0. unsigned getRegisterForVar(InlinedEntity Var) const; - bool empty() const { return VarInstrRanges.empty(); } - void clear() { VarInstrRanges.clear(); } - InstrRangesMap::const_iterator begin() const { return VarInstrRanges.begin(); } - InstrRangesMap::const_iterator end() const { return VarInstrRanges.end(); } + bool empty() const { return VarEntries.empty(); } + void clear() { VarEntries.clear(); } + EntriesMap::const_iterator begin() const { return VarEntries.begin(); } + EntriesMap::const_iterator end() const { return VarEntries.end(); } #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) LLVM_DUMP_METHOD void dump() const; Index: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h =================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h +++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h @@ -222,7 +222,7 @@ codeview::TypeIndex getFuncIdForSubprogram(const DISubprogram *SP); void calculateRanges(LocalVariable &Var, - const DbgValueHistoryMap::InstrRanges &Ranges); + const DbgValueHistoryMap::Entries &Entries); static void collectInlineSiteChildren(SmallVectorImpl &Children, const FunctionInfo &FI, Index: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp =================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp +++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp @@ -1154,13 +1154,13 @@ } void CodeViewDebug::calculateRanges( - LocalVariable &Var, const DbgValueHistoryMap::InstrRanges &Ranges) { + LocalVariable &Var, const DbgValueHistoryMap::Entries &Entries) { const TargetRegisterInfo *TRI = Asm->MF->getSubtarget().getRegisterInfo(); // Calculate the definition ranges. - for (auto I = Ranges.begin(), E = Ranges.end(); I != E; ++I) { - const auto &Range = *I; - const MachineInstr *DVInst = Range.getBegin(); + for (auto I = Entries.begin(), E = Entries.end(); I != E; ++I) { + const auto &Entry = *I; + const MachineInstr *DVInst = Entry.getBegin(); assert(DVInst->isDebugValue() && "Invalid History entry"); // FIXME: Find a way to represent constant variables, since they are // relatively common. @@ -1187,7 +1187,7 @@ // Start over using that. Var.UseReferenceType = true; Var.DefRanges.clear(); - calculateRanges(Var, Ranges); + calculateRanges(Var, Entries); return; } @@ -1215,8 +1215,8 @@ } // Compute the label range. - const MCSymbol *Begin = getLabelBeforeInsn(Range.getBegin()); - const MCSymbol *End = getLabelAfterInsn(Range.getEnd()); + const MCSymbol *Begin = getLabelBeforeInsn(Entry.getBegin()); + const MCSymbol *End = getLabelAfterInsn(Entry.getEnd()); if (!End) { // This range is valid until the next overlapping bitpiece. In the // common case, ranges will not be bitpieces, so they will overlap. @@ -1257,7 +1257,7 @@ const DILocation *InlinedAt = IV.second; // Instruction ranges, specifying where IV is accessible. - const auto &Ranges = I.second; + const auto &Entries = I.second; LexicalScope *Scope = nullptr; if (InlinedAt) @@ -1271,7 +1271,7 @@ LocalVariable Var; Var.DIVar = DIVar; - calculateRanges(Var, Ranges); + calculateRanges(Var, Entries); recordLocalVariable(std::move(Var), Scope); } } Index: llvm/trunk/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp =================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp +++ llvm/trunk/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp @@ -41,30 +41,28 @@ return MI.getOperand(0).isReg() ? MI.getOperand(0).getReg() : 0; } -void DbgValueHistoryMap::startInstrRange(InlinedEntity Var, - const MachineInstr &MI) { +void DbgValueHistoryMap::startEntry(InlinedEntity Var, const MachineInstr &MI) { // Instruction range should start with a DBG_VALUE instruction for the // variable. assert(MI.isDebugValue() && "not a DBG_VALUE"); - auto &Ranges = VarInstrRanges[Var]; - if (!Ranges.empty() && !Ranges.back().isClosed() && - Ranges.back().getBegin()->isIdenticalTo(MI)) { + auto &Entries = VarEntries[Var]; + if (!Entries.empty() && !Entries.back().isClosed() && + Entries.back().getBegin()->isIdenticalTo(MI)) { LLVM_DEBUG(dbgs() << "Coalescing identical DBG_VALUE entries:\n" - << "\t" << Ranges.back().getBegin() << "\t" << MI + << "\t" << Entries.back().getBegin() << "\t" << MI << "\n"); return; } - Ranges.emplace_back(&MI); + Entries.emplace_back(&MI); } -void DbgValueHistoryMap::endInstrRange(InlinedEntity Var, - const MachineInstr &MI) { - auto &Ranges = VarInstrRanges[Var]; - assert(!Ranges.empty() && "No range exists for variable!"); - Ranges.back().endRange(MI); +void DbgValueHistoryMap::endEntry(InlinedEntity Var, const MachineInstr &MI) { + auto &Entries = VarEntries[Var]; + assert(!Entries.empty() && "No range exists for variable!"); + Entries.back().endEntry(MI); } -void DbgValueHistoryMap::InstrRange::endRange(const MachineInstr &MI) { +void DbgValueHistoryMap::Entry::endEntry(const MachineInstr &MI) { // For now, instruction ranges are not allowed to cross basic block // boundaries. assert(Begin->getParent() == MI.getParent()); @@ -73,13 +71,13 @@ } unsigned DbgValueHistoryMap::getRegisterForVar(InlinedEntity Var) const { - const auto &I = VarInstrRanges.find(Var); - if (I == VarInstrRanges.end()) + const auto &I = VarEntries.find(Var); + if (I == VarEntries.end()) return 0; - const auto &Ranges = I->second; - if (Ranges.empty() || Ranges.back().isClosed()) + const auto &Entries = I->second; + if (Entries.empty() || Entries.back().isClosed()) return 0; - return isDescribedByReg(*Ranges.back().getBegin()); + return isDescribedByReg(*Entries.back().getBegin()); } void DbgLabelInstrMap::addInstr(InlinedEntity Label, const MachineInstr &MI) { @@ -127,7 +125,7 @@ // Iterate over all variables described by this register and add this // instruction to their history, clobbering it. for (const auto &Var : I->second) - HistMap.endInstrRange(Var, ClobberingInstr); + HistMap.endEntry(Var, ClobberingInstr); RegVars.erase(I); } @@ -257,7 +255,7 @@ if (unsigned PrevReg = DbgValues.getRegisterForVar(Var)) dropRegDescribedVar(RegVars, PrevReg, Var); - DbgValues.startInstrRange(Var, MI); + DbgValues.startEntry(Var, MI); if (unsigned NewReg = isDescribedByReg(MI)) addRegDescribedVar(RegVars, NewReg, Var); @@ -293,7 +291,7 @@ dbgs() << "DbgValueHistoryMap:\n"; for (const auto &VarRangePair : *this) { const InlinedEntity &Var = VarRangePair.first; - const InstrRanges &Ranges = VarRangePair.second; + const Entries &Entries = VarRangePair.second; const DILocalVariable *LocalVar = cast(Var.first); const DILocation *Location = Var.second; @@ -308,10 +306,10 @@ dbgs() << " --\n"; - for (const InstrRange &Range : Ranges) { - dbgs() << " Begin: " << *Range.getBegin(); - if (Range.getEnd()) - dbgs() << " End : " << *Range.getEnd(); + for (const auto &Entry : Entries) { + dbgs() << " Begin: " << *Entry.getBegin(); + if (Entry.getEnd()) + dbgs() << " End : " << *Entry.getEnd(); dbgs() << "\n"; } } Index: llvm/trunk/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp =================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp +++ llvm/trunk/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp @@ -211,8 +211,8 @@ // Request labels for the full history. for (const auto &I : DbgValues) { - const auto &Ranges = I.second; - if (Ranges.empty()) + const auto &Entries = I.second; + if (Entries.empty()) continue; auto IsDescribedByReg = [](const MachineInstr *MI) { @@ -229,17 +229,17 @@ // However, we currently do not emit debug values for constant arguments // directly at the start of the function, so this code is still useful. const DILocalVariable *DIVar = - Ranges.front().getBegin()->getDebugVariable(); + Entries.front().getBegin()->getDebugVariable(); if (DIVar->isParameter() && getDISubprogram(DIVar->getScope())->describes(&MF->getFunction())) { - if (!IsDescribedByReg(Ranges.front().getBegin())) - LabelsBeforeInsn[Ranges.front().getBegin()] = Asm->getFunctionBegin(); - if (Ranges.front().getBegin()->getDebugExpression()->isFragment()) { + if (!IsDescribedByReg(Entries.front().getBegin())) + LabelsBeforeInsn[Entries.front().getBegin()] = Asm->getFunctionBegin(); + if (Entries.front().getBegin()->getDebugExpression()->isFragment()) { // Mark all non-overlapping initial fragments. - for (auto I = Ranges.begin(); I != Ranges.end(); ++I) { + for (auto I = Entries.begin(); I != Entries.end(); ++I) { const DIExpression *Fragment = I->getBegin()->getDebugExpression(); - if (std::any_of(Ranges.begin(), I, - [&](DbgValueHistoryMap::InstrRange Pred) { + if (std::any_of(Entries.begin(), I, + [&](DbgValueHistoryMap::Entry Pred) { return Fragment->fragmentsOverlap( Pred.getBegin()->getDebugExpression()); })) @@ -250,10 +250,10 @@ } } - for (const auto &Range : Ranges) { - requestLabelBeforeInsn(Range.getBegin()); - if (Range.getEnd()) - requestLabelAfterInsn(Range.getEnd()); + for (const auto &Entry : Entries) { + requestLabelBeforeInsn(Entry.getBegin()); + if (Entry.getEnd()) + requestLabelAfterInsn(Entry.getEnd()); } } Index: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h =================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -559,7 +559,7 @@ /// Build the location list for all DBG_VALUEs in the /// function that describe the same variable. void buildLocationList(SmallVectorImpl &DebugLoc, - const DbgValueHistoryMap::InstrRanges &Ranges); + const DbgValueHistoryMap::Entries &Entries); /// Collect variable information from the side table maintained by MF. void collectVariableInfoFromMFTable(DwarfCompileUnit &TheCU, Index: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp =================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -1117,14 +1117,13 @@ // [1-3] [x, (reg0, fragment 0, 32), (reg1, fragment 32, 32)] // [3-4] [x, (reg1, fragment 32, 32)] // [4- ] [x, (mem, fragment 0, 64)] -void -DwarfDebug::buildLocationList(SmallVectorImpl &DebugLoc, - const DbgValueHistoryMap::InstrRanges &Ranges) { +void DwarfDebug::buildLocationList(SmallVectorImpl &DebugLoc, + const DbgValueHistoryMap::Entries &Entries) { SmallVector OpenRanges; - for (auto I = Ranges.begin(), E = Ranges.end(); I != E; ++I) { - const MachineInstr *Begin = I->getBegin(); - const MachineInstr *End = I->getEnd(); + for (auto EI = Entries.begin(), EE = Entries.end(); EI != EE; ++EI) { + const MachineInstr *Begin = EI->getBegin(); + const MachineInstr *End = EI->getEnd(); assert(Begin->isDebugValue() && "Invalid History entry"); // Check if a variable is inaccessible in this range. @@ -1147,10 +1146,10 @@ const MCSymbol *EndLabel; if (End != nullptr) EndLabel = getLabelAfterInsn(End); - else if (std::next(I) == Ranges.end()) + else if (std::next(EI) == Entries.end()) EndLabel = Asm->getFunctionEnd(); else - EndLabel = getLabelBeforeInsn(std::next(I)->getBegin()); + EndLabel = getLabelBeforeInsn(std::next(EI)->getBegin()); assert(EndLabel && "Forgot label after instruction ending a range!"); LLVM_DEBUG(dbgs() << "DotDebugLoc: " << *Begin << "\n"); @@ -1275,8 +1274,8 @@ continue; // Instruction ranges, specifying where IV is accessible. - const auto &Ranges = I.second; - if (Ranges.empty()) + const auto &HistoryMapEntries = I.second; + if (HistoryMapEntries.empty()) continue; LexicalScope *Scope = nullptr; @@ -1293,12 +1292,12 @@ DbgVariable *RegVar = cast(createConcreteEntity(TheCU, *Scope, LocalVar, IV.second)); - const MachineInstr *MInsn = Ranges.front().getBegin(); + const MachineInstr *MInsn = HistoryMapEntries.front().getBegin(); assert(MInsn->isDebugValue() && "History must begin with debug value"); // Check if there is a single DBG_VALUE, valid throughout the var's scope. - if (Ranges.size() == 1 && - validThroughout(LScopes, MInsn, Ranges.front().getEnd())) { + if (HistoryMapEntries.size() == 1 && + validThroughout(LScopes, MInsn, HistoryMapEntries.front().getEnd())) { RegVar->initializeDbgValue(MInsn); continue; } @@ -1311,7 +1310,7 @@ // Build the location list for this variable. SmallVector Entries; - buildLocationList(Entries, Ranges); + buildLocationList(Entries, HistoryMapEntries); // If the variable has a DIBasicType, extract it. Basic types cannot have // unique identifiers, so don't bother resolving the type with the