summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp135
1 files changed, 45 insertions, 90 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 53314af6882..8761fae9dd2 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -188,12 +188,12 @@ bool DebugLocDwarfExpression::isFrameRegister(const TargetRegisterInfo &TRI,
}
bool DbgVariable::isBlockByrefVariable() const {
- assert(getVariable() && "Invalid complex DbgVariable!");
- return getVariable()->getType().resolve()->isBlockByrefStruct();
+ assert(Var && "Invalid complex DbgVariable!");
+ return Var->getType().resolve()->isBlockByrefStruct();
}
const DIType *DbgVariable::getType() const {
- DIType *Ty = getVariable()->getType().resolve();
+ DIType *Ty = Var->getType().resolve();
// FIXME: isBlockByrefVariable should be reformulated in terms of complex
// addresses instead.
if (Ty->isBlockByrefStruct()) {
@@ -258,8 +258,8 @@ ArrayRef<DbgVariable::FrameIndexExpr> DbgVariable::getFrameIndexExprs() const {
void DbgVariable::addMMIEntry(const DbgVariable &V) {
assert(DebugLocListIndex == ~0U && !MInsn && "not an MMI entry");
assert(V.DebugLocListIndex == ~0U && !V.MInsn && "not an MMI entry");
- assert(V.getVariable() == getVariable() && "conflicting variable");
- assert(V.getInlinedAt() == getInlinedAt() && "conflicting inlined-at location");
+ assert(V.Var == Var && "conflicting variable");
+ assert(V.IA == IA && "conflicting inlined-at location");
assert(!FrameIndexExprs.empty() && "Expected an MMI entry");
assert(!V.FrameIndexExprs.empty() && "Expected an MMI entry");
@@ -726,16 +726,16 @@ void DwarfDebug::beginModule() {
}
}
-void DwarfDebug::finishEntityDefinitions() {
- for (const auto &Entity : ConcreteEntities) {
- DIE *Die = Entity->getDIE();
- assert(Die);
+void DwarfDebug::finishVariableDefinitions() {
+ for (const auto &Var : ConcreteVariables) {
+ DIE *VariableDie = Var->getDIE();
+ assert(VariableDie);
// FIXME: Consider the time-space tradeoff of just storing the unit pointer
- // in the ConcreteEntities list, rather than looking it up again here.
+ // in the ConcreteVariables list, rather than looking it up again here.
// DIE::getUnit isn't simple - it walks parent pointers, etc.
- DwarfCompileUnit *Unit = CUDieMap.lookup(Die->getUnitDie());
+ DwarfCompileUnit *Unit = CUDieMap.lookup(VariableDie->getUnitDie());
assert(Unit);
- Unit->finishEntityDefinition(Entity.get());
+ Unit->finishVariableDefinition(*Var);
}
}
@@ -753,7 +753,7 @@ void DwarfDebug::finalizeModuleInfo() {
finishSubprogramDefinitions();
- finishEntityDefinitions();
+ finishVariableDefinitions();
// Include the DWO file name in the hash if there's more than one CU.
// This handles ThinLTO's situation where imported CUs may very easily be
@@ -914,24 +914,25 @@ void DwarfDebug::endModule() {
// FIXME: AbstractVariables.clear();
}
-void DwarfDebug::ensureAbstractEntityIsCreated(DwarfCompileUnit &CU,
- const DINode *Node,
- const MDNode *ScopeNode) {
- if (CU.getExistingAbstractEntity(Node))
+void DwarfDebug::ensureAbstractVariableIsCreated(DwarfCompileUnit &CU, InlinedVariable IV,
+ const MDNode *ScopeNode) {
+ const DILocalVariable *Cleansed = nullptr;
+ if (CU.getExistingAbstractVariable(IV, Cleansed))
return;
- CU.createAbstractEntity(Node, LScopes.getOrCreateAbstractScope(
+ CU.createAbstractVariable(Cleansed, LScopes.getOrCreateAbstractScope(
cast<DILocalScope>(ScopeNode)));
}
-void DwarfDebug::ensureAbstractEntityIsCreatedIfScoped(DwarfCompileUnit &CU,
- const DINode *Node, const MDNode *ScopeNode) {
- if (CU.getExistingAbstractEntity(Node))
+void DwarfDebug::ensureAbstractVariableIsCreatedIfScoped(DwarfCompileUnit &CU,
+ InlinedVariable IV, const MDNode *ScopeNode) {
+ const DILocalVariable *Cleansed = nullptr;
+ if (CU.getExistingAbstractVariable(IV, Cleansed))
return;
if (LexicalScope *Scope =
LScopes.findAbstractScope(cast_or_null<DILocalScope>(ScopeNode)))
- CU.createAbstractEntity(Node, Scope);
+ CU.createAbstractVariable(Cleansed, Scope);
}
// Collect variable information from side table maintained by MF.
@@ -952,14 +953,14 @@ void DwarfDebug::collectVariableInfoFromMFTable(
if (!Scope)
continue;
- ensureAbstractEntityIsCreatedIfScoped(TheCU, Var.first, Scope->getScopeNode());
+ ensureAbstractVariableIsCreatedIfScoped(TheCU, Var, Scope->getScopeNode());
auto RegVar = llvm::make_unique<DbgVariable>(Var.first, Var.second);
RegVar->initializeMMI(VI.Expr, VI.Slot);
if (DbgVariable *DbgVar = MFVars.lookup(Var))
DbgVar->addMMIEntry(*RegVar);
else if (InfoHolder.addScopeVariable(Scope, RegVar.get())) {
MFVars.insert({Var, RegVar.get()});
- ConcreteEntities.push_back(std::move(RegVar));
+ ConcreteVariables.push_back(std::move(RegVar));
}
}
}
@@ -1124,26 +1125,14 @@ DwarfDebug::buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
}
}
-DbgEntity *DwarfDebug::createConcreteEntity(DwarfCompileUnit &TheCU,
- LexicalScope &Scope,
- const DINode *Node,
- const DILocation *Location,
- const MCSymbol *Sym) {
- ensureAbstractEntityIsCreatedIfScoped(TheCU, Node, Scope.getScopeNode());
- if (isa<const DILocalVariable>(Node)) {
- ConcreteEntities.push_back(
- llvm::make_unique<DbgVariable>(cast<const DILocalVariable>(Node),
- Location));
- InfoHolder.addScopeVariable(&Scope,
- cast<DbgVariable>(ConcreteEntities.back().get()));
- } else if (isa<const DILabel>(Node)) {
- ConcreteEntities.push_back(
- llvm::make_unique<DbgLabel>(cast<const DILabel>(Node),
- Location, Sym));
- InfoHolder.addScopeLabel(&Scope,
- cast<DbgLabel>(ConcreteEntities.back().get()));
- }
- return ConcreteEntities.back().get();
+DbgVariable *DwarfDebug::createConcreteVariable(DwarfCompileUnit &TheCU,
+ LexicalScope &Scope,
+ InlinedVariable IV) {
+ ensureAbstractVariableIsCreatedIfScoped(TheCU, IV, Scope.getScopeNode());
+ ConcreteVariables.push_back(
+ llvm::make_unique<DbgVariable>(IV.first, IV.second));
+ InfoHolder.addScopeVariable(&Scope, ConcreteVariables.back().get());
+ return ConcreteVariables.back().get();
}
/// Determine whether a *singular* DBG_VALUE is valid for the entirety of its
@@ -1205,9 +1194,9 @@ static bool validThroughout(LexicalScopes &LScopes,
}
// Find variables for each lexical scope.
-void DwarfDebug::collectEntityInfo(DwarfCompileUnit &TheCU,
- const DISubprogram *SP,
- DenseSet<InlinedVariable> &Processed) {
+void DwarfDebug::collectVariableInfo(DwarfCompileUnit &TheCU,
+ const DISubprogram *SP,
+ DenseSet<InlinedVariable> &Processed) {
// Grab the variable info that was squirreled away in the MMI side-table.
collectVariableInfoFromMFTable(TheCU, Processed);
@@ -1231,8 +1220,7 @@ void DwarfDebug::collectEntityInfo(DwarfCompileUnit &TheCU,
continue;
Processed.insert(IV);
- DbgVariable *RegVar = cast<DbgVariable>(createConcreteEntity(TheCU,
- *Scope, IV.first, IV.second));
+ DbgVariable *RegVar = createConcreteVariable(TheCU, *Scope, IV);
const MachineInstr *MInsn = Ranges.front().first;
assert(MInsn->isDebugValue() && "History must begin with debug value");
@@ -1265,44 +1253,13 @@ void DwarfDebug::collectEntityInfo(DwarfCompileUnit &TheCU,
Entry.finalize(*Asm, List, BT);
}
- // For each InlinedLabel collected from DBG_LABEL instructions, convert to
- // DWARF-related DbgLabel.
- for (const auto &I : DbgLabels) {
- InlinedLabel IL = I.first;
- const MachineInstr *MI = I.second;
- if (MI == nullptr)
- continue;
-
- LexicalScope *Scope = nullptr;
- // Get inlined DILocation if it is inlined label.
- if (const DILocation *IA = IL.second)
- Scope = LScopes.findInlinedScope(IL.first->getScope(), IA);
- else
- Scope = LScopes.findLexicalScope(IL.first->getScope());
- // If label scope is not found then skip this label.
- if (!Scope)
- continue;
-
- /// At this point, the temporary label is created.
- /// Save the temporary label to DbgLabel entity to get the
- /// actually address when generating Dwarf DIE.
- MCSymbol *Sym = getLabelBeforeInsn(MI);
- createConcreteEntity(TheCU, *Scope, IL.first, IL.second, Sym);
- }
-
- // Collect info for variables/labels that were optimized out.
+ // Collect info for variables that were optimized out.
for (const DINode *DN : SP->getRetainedNodes()) {
- LexicalScope *Scope = nullptr;
if (auto *DV = dyn_cast<DILocalVariable>(DN)) {
- if (!Processed.insert(InlinedVariable(DV, nullptr)).second)
- continue;
- Scope = LScopes.findLexicalScope(DV->getScope());
- } else if (auto *DL = dyn_cast<DILabel>(DN)) {
- Scope = LScopes.findLexicalScope(DL->getScope());
+ if (Processed.insert(InlinedVariable(DV, nullptr)).second)
+ if (LexicalScope *Scope = LScopes.findLexicalScope(DV->getScope()))
+ createConcreteVariable(TheCU, *Scope, InlinedVariable(DV, nullptr));
}
-
- if (Scope)
- createConcreteEntity(TheCU, *Scope, DN, nullptr);
}
}
@@ -1460,7 +1417,7 @@ void DwarfDebug::endFunctionImpl(const MachineFunction *MF) {
DwarfCompileUnit &TheCU = *CUMap.lookup(SP->getUnit());
DenseSet<InlinedVariable> ProcessedVars;
- collectEntityInfo(TheCU, SP, ProcessedVars);
+ collectVariableInfo(TheCU, SP, ProcessedVars);
// Add the range of this function to the list of ranges for the CU.
TheCU.addRange(RangeSpan(Asm->getFunctionBegin(), Asm->getFunctionEnd()));
@@ -1488,11 +1445,10 @@ void DwarfDebug::endFunctionImpl(const MachineFunction *MF) {
// Collect info for variables that were optimized out.
if (!ProcessedVars.insert(InlinedVariable(DV, nullptr)).second)
continue;
- ensureAbstractEntityIsCreated(TheCU, DV, DV->getScope());
+ ensureAbstractVariableIsCreated(TheCU, InlinedVariable(DV, nullptr),
+ DV->getScope());
assert(LScopes.getAbstractScopesList().size() == NumAbstractScopes
- && "ensureAbstractEntityIsCreated inserted abstract scopes");
- } else if (auto *DL = dyn_cast<DILabel>(DN)) {
- ensureAbstractEntityIsCreated(TheCU, DL, DL->getScope());
+ && "ensureAbstractVariableIsCreated inserted abstract scopes");
}
}
constructAbstractSubprogramScopeDIE(TheCU, AScope);
@@ -1510,7 +1466,6 @@ void DwarfDebug::endFunctionImpl(const MachineFunction *MF) {
// DbgVariables except those that are also in AbstractVariables (since they
// can be used cross-function)
InfoHolder.getScopeVariables().clear();
- InfoHolder.getScopeLabels().clear();
PrevLabel = nullptr;
CurFn = nullptr;
}
OpenPOWER on IntegriCloud