summaryrefslogtreecommitdiff
path: root/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2014-06-13 22:18:23 +0000
committerDavid Blaikie <dblaikie@gmail.com>2014-06-13 22:18:23 +0000
commit0fcb9cb1c11b209774bb7dc4f23e796b7cafdbf3 (patch)
tree314e21f1df4dff57e3f9cb2336baf4dca02f23b9 /lib/CodeGen/AsmPrinter/DwarfDebug.cpp
parentc4268a67950514b1e5f2f602882dc7c22609c448 (diff)
downloadllvm-0fcb9cb1c11b209774bb7dc4f23e796b7cafdbf3.tar.gz
llvm-0fcb9cb1c11b209774bb7dc4f23e796b7cafdbf3.tar.bz2
llvm-0fcb9cb1c11b209774bb7dc4f23e796b7cafdbf3.tar.xz
DebugInfo: Following up to r209677, refactor local variable emission to delay the choice between emitting the definition attributes or using DW_AT_abstract_definition
This doesn't fix the abstract variable handling yet, but it introduces a similar delay mechanism as was added for subprograms, causing DW_AT_location to be reordered to the beginning of the attribute list for local variables, and fixes all the test fallout for that. A subsequent commit will remove the abstract variable handling in DbgVariable and just do the abstract variable lookup at module end to ensure that abstract variables introduced after their concrete counterparts are appropriately referenced by the concrete variable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210943 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/AsmPrinter/DwarfDebug.cpp')
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfDebug.cpp41
1 files changed, 30 insertions, 11 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 433cc3769e..1284d1c922 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -783,6 +783,23 @@ void DwarfDebug::beginModule() {
SectionMap[Asm->getObjFileLowering().getTextSection()];
}
+void DwarfDebug::finishVariableDefinitions() {
+ for (const auto &Var : ConcreteVariables) {
+ DIE *VariableDie = Var->getDIE();
+ // FIXME: Consider the time-space tradeoff of just storing the unit pointer
+ // in the ConcreteVariables list, rather than looking it up again here.
+ // DIE::getUnit isn't simple - it walks parent pointers, etc.
+ DwarfCompileUnit *Unit = lookupUnit(VariableDie->getUnit());
+ assert(Unit);
+ DbgVariable *AbsVar = Var->getAbstractVariable();
+ if (AbsVar && AbsVar->getDIE()) {
+ Unit->addDIEEntry(*VariableDie, dwarf::DW_AT_abstract_origin,
+ *AbsVar->getDIE());
+ } else
+ Unit->applyVariableAttributes(*Var, *VariableDie);
+ }
+}
+
void DwarfDebug::finishSubprogramDefinitions() {
const Module *M = MMI->getModule();
@@ -849,7 +866,9 @@ void DwarfDebug::collectDeadVariables() {
DIVariable DV(Variables.getElement(vi));
assert(DV.isVariable());
DbgVariable NewVar(DV, nullptr, this);
- SPDIE->addChild(SPCU->constructVariableDIE(NewVar));
+ auto VariableDie = SPCU->constructVariableDIE(NewVar);
+ SPCU->applyVariableAttributes(NewVar, *VariableDie);
+ SPDIE->addChild(std::move(VariableDie));
}
}
}
@@ -859,6 +878,8 @@ void DwarfDebug::collectDeadVariables() {
void DwarfDebug::finalizeModuleInfo() {
finishSubprogramDefinitions();
+ finishVariableDefinitions();
+
// Collect info for variables that were optimized out.
collectDeadVariables();
@@ -1126,7 +1147,8 @@ void DwarfDebug::collectVariableInfoFromMMITable(
DbgVariable *AbsDbgVariable =
findAbstractVariable(DV, Scope->getScopeNode());
- DbgVariable *RegVar = new DbgVariable(DV, AbsDbgVariable, this);
+ ConcreteVariables.push_back(make_unique<DbgVariable>(DV, AbsDbgVariable, this));
+ DbgVariable *RegVar = ConcreteVariables.back().get();
RegVar->setFrameIndex(VI.Slot);
addScopeVariable(Scope, RegVar);
}
@@ -1194,7 +1216,8 @@ DwarfDebug::collectVariableInfo(SmallPtrSet<const MDNode *, 16> &Processed) {
const MachineInstr *MInsn = Ranges.front().first;
assert(MInsn->isDebugValue() && "History must begin with debug value");
DbgVariable *AbsVar = findAbstractVariable(DV, Scope->getScopeNode());
- DbgVariable *RegVar = new DbgVariable(MInsn, AbsVar, this);
+ ConcreteVariables.push_back(make_unique<DbgVariable>(MInsn, AbsVar, this));
+ DbgVariable *RegVar = ConcreteVariables.back().get();
addScopeVariable(Scope, RegVar);
// Check if the first DBG_VALUE is valid for the rest of the function.
@@ -1250,9 +1273,9 @@ DwarfDebug::collectVariableInfo(SmallPtrSet<const MDNode *, 16> &Processed) {
if (!Processed.insert(DV))
continue;
if (LexicalScope *Scope = LScopes.findLexicalScope(DV.getContext())) {
- auto *RegVar = new DbgVariable(
- DV, findAbstractVariable(DV, Scope->getScopeNode()), this);
- addScopeVariable(Scope, RegVar);
+ ConcreteVariables.push_back(make_unique<DbgVariable>(
+ DV, findAbstractVariable(DV, Scope->getScopeNode()), this));
+ addScopeVariable(Scope, ConcreteVariables.back().get());
}
}
}
@@ -1554,12 +1577,8 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {
// Ownership of DbgVariables is a bit subtle - ScopeVariables owns all the
// DbgVariables except those that are also in AbstractVariables (since they
// can be used cross-function)
- for (const auto &I : ScopeVariables)
- for (const auto *Var : I.second)
- if (!AbstractVariables.count(Var->getVariable()) || Var->getAbstractVariable())
- delete Var;
ScopeVariables.clear();
- DeleteContainerPointers(CurrentFnArguments);
+ CurrentFnArguments.clear();
DbgValues.clear();
LabelsBeforeInsn.clear();
LabelsAfterInsn.clear();