/// 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<InstrRange, 4>;
+ using Entries = SmallVector<Entry, 4>;
using InlinedEntity = std::pair<const DINode *, const DILocation *>;
- using InstrRangesMap = MapVector<InlinedEntity, InstrRanges>;
+ using EntriesMap = MapVector<InlinedEntity, Entries>;
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;
}
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.
// Start over using that.
Var.UseReferenceType = true;
Var.DefRanges.clear();
- calculateRanges(Var, Ranges);
+ calculateRanges(Var, Entries);
return;
}
}
// 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.
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)
LocalVariable Var;
Var.DIVar = DIVar;
- calculateRanges(Var, Ranges);
+ calculateRanges(Var, Entries);
recordLocalVariable(std::move(Var), Scope);
}
}
codeview::TypeIndex getFuncIdForSubprogram(const DISubprogram *SP);
void calculateRanges(LocalVariable &Var,
- const DbgValueHistoryMap::InstrRanges &Ranges);
+ const DbgValueHistoryMap::Entries &Entries);
static void collectInlineSiteChildren(SmallVectorImpl<unsigned> &Children,
const FunctionInfo &FI,
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());
}
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) {
// 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);
}
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);
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<DILocalVariable>(Var.first);
const DILocation *Location = Var.second;
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";
}
}
// 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) {
// 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());
}))
}
}
- 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());
}
}
// [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<DebugLocEntry> &DebugLoc,
- const DbgValueHistoryMap::InstrRanges &Ranges) {
+void DwarfDebug::buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
+ const DbgValueHistoryMap::Entries &Entries) {
SmallVector<DebugLocEntry::Value, 4> 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.
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");
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;
DbgVariable *RegVar = cast<DbgVariable>(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;
}
// Build the location list for this variable.
SmallVector<DebugLocEntry, 8> 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
/// Build the location list for all DBG_VALUEs in the
/// function that describe the same variable.
void buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
- const DbgValueHistoryMap::InstrRanges &Ranges);
+ const DbgValueHistoryMap::Entries &Entries);
/// Collect variable information from the side table maintained by MF.
void collectVariableInfoFromMFTable(DwarfCompileUnit &TheCU,