aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
diff options
context:
space:
mode:
authorBruno Cardoso Lopes <bruno.cardoso@gmail.com>2018-08-14 17:54:41 +0000
committerBruno Cardoso Lopes <bruno.cardoso@gmail.com>2018-08-14 17:54:41 +0000
commitf446282aad4ce40b0c4570813261b78c527a588b (patch)
tree4da6c331bd1e47a55daa209be5c40cba48d6ae98 /llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
parentabf94118c5561171bab909c08ae5b89fada1ffa7 (diff)
downloadllvm-f446282aad4ce40b0c4570813261b78c527a588b.zip
llvm-f446282aad4ce40b0c4570813261b78c527a588b.tar.gz
llvm-f446282aad4ce40b0c4570813261b78c527a588b.tar.bz2
Revert "[DebugInfo] Generate DWARF debug information for labels. (Fix leak problems)"
This reverts commit cb8c5e417d55141f3f079a8a876e786f44308336 / r339676. This causing a test to fail in http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/48406/ LLVM :: DebugInfo/Generic/debug-label.ll llvm-svn: 339700
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp88
1 files changed, 26 insertions, 62 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index 532eb9e..322555a 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -513,18 +513,6 @@ DIE *DwarfCompileUnit::constructVariableDIE(DbgVariable &DV, bool Abstract) {
return D;
}
-DIE *DwarfCompileUnit::constructLabelDIE(DbgLabel &DL,
- const LexicalScope &Scope) {
- auto LabelDie = DIE::get(DIEValueAllocator, DL.getTag());
- insertDIE(DL.getLabel(), LabelDie);
- DL.setDIE(*LabelDie);
-
- if (Scope.isAbstractScope())
- applyLabelAttributes(DL, *LabelDie);
-
- return LabelDie;
-}
-
DIE *DwarfCompileUnit::constructVariableDIEImpl(const DbgVariable &DV,
bool Abstract) {
// Define variable debug information entry.
@@ -718,9 +706,6 @@ DIE *DwarfCompileUnit::createScopeChildrenDIE(LexicalScope *Scope,
if (HasNonScopeChildren)
*HasNonScopeChildren = !Children.empty();
- for (DbgLabel *DL : DU->getScopeLabels().lookup(Scope))
- Children.push_back(constructLabelDIE(*DL, *Scope));
-
for (LexicalScope *LS : Scope->getChildren())
constructScopeDIE(LS, Children);
@@ -846,52 +831,40 @@ void DwarfCompileUnit::finishSubprogramDefinition(const DISubprogram *SP) {
}
}
-void DwarfCompileUnit::finishEntityDefinition(const DbgEntity *Entity) {
- DbgEntity *AbsEntity = getExistingAbstractEntity(Entity->getEntity());
-
- auto *Die = Entity->getDIE();
- /// Label may be used to generate DW_AT_low_pc, so put it outside
- /// if/else block.
- const DbgLabel *Label = nullptr;
- if (AbsEntity && AbsEntity->getDIE()) {
- addDIEEntry(*Die, dwarf::DW_AT_abstract_origin, *AbsEntity->getDIE());
- Label = dyn_cast<const DbgLabel>(Entity);
- } else {
- if (const DbgVariable *Var = dyn_cast<const DbgVariable>(Entity))
- applyVariableAttributes(*Var, *Die);
- else if ((Label = dyn_cast<const DbgLabel>(Entity)))
- applyLabelAttributes(*Label, *Die);
- else
- llvm_unreachable("DbgEntity must be DbgVariable or DbgLabel.");
- }
+void DwarfCompileUnit::finishVariableDefinition(const DbgVariable &Var) {
+ DbgVariable *AbsVar = getExistingAbstractVariable(
+ InlinedVariable(Var.getVariable(), Var.getInlinedAt()));
+ auto *VariableDie = Var.getDIE();
+ if (AbsVar && AbsVar->getDIE()) {
+ addDIEEntry(*VariableDie, dwarf::DW_AT_abstract_origin,
+ *AbsVar->getDIE());
+ } else
+ applyVariableAttributes(Var, *VariableDie);
+}
- if (Label) {
- const MCSymbol *Sym = Label->getSymbol();
- addLabelAddress(*Die, dwarf::DW_AT_low_pc, Sym);
- }
+DbgVariable *DwarfCompileUnit::getExistingAbstractVariable(InlinedVariable IV) {
+ const DILocalVariable *Cleansed;
+ return getExistingAbstractVariable(IV, Cleansed);
}
-DbgEntity *DwarfCompileUnit::getExistingAbstractEntity(const DINode *Node) {
- auto &AbstractEntities = getAbstractEntities();
- auto I = AbstractEntities.find(Node);
- if (I != AbstractEntities.end())
+// Find abstract variable, if any, associated with Var.
+DbgVariable *DwarfCompileUnit::getExistingAbstractVariable(
+ InlinedVariable IV, const DILocalVariable *&Cleansed) {
+ // More then one inlined variable corresponds to one abstract variable.
+ Cleansed = IV.first;
+ auto &AbstractVariables = getAbstractVariables();
+ auto I = AbstractVariables.find(Cleansed);
+ if (I != AbstractVariables.end())
return I->second.get();
return nullptr;
}
-void DwarfCompileUnit::createAbstractEntity(const DINode *Node,
- LexicalScope *Scope) {
+void DwarfCompileUnit::createAbstractVariable(const DILocalVariable *Var,
+ LexicalScope *Scope) {
assert(Scope && Scope->isAbstractScope());
- auto &Entity = getAbstractEntities()[Node];
- if (isa<const DILocalVariable>(Node)) {
- Entity = llvm::make_unique<DbgVariable>(
- cast<const DILocalVariable>(Node), nullptr /* IA */);;
- DU->addScopeVariable(Scope, cast<DbgVariable>(Entity.get()));
- } else if (isa<const DILabel>(Node)) {
- Entity = llvm::make_unique<DbgLabel>(
- cast<const DILabel>(Node), nullptr /* IA */);
- DU->addScopeLabel(Scope, cast<DbgLabel>(Entity.get()));
- }
+ auto AbsDbgVariable = llvm::make_unique<DbgVariable>(Var, /* IA */ nullptr);
+ DU->addScopeVariable(Scope, AbsDbgVariable.get());
+ getAbstractVariables()[Var] = std::move(AbsDbgVariable);
}
void DwarfCompileUnit::emitHeader(bool UseOffsets) {
@@ -1046,15 +1019,6 @@ void DwarfCompileUnit::applyVariableAttributes(const DbgVariable &Var,
addFlag(VariableDie, dwarf::DW_AT_artificial);
}
-void DwarfCompileUnit::applyLabelAttributes(const DbgLabel &Label,
- DIE &LabelDie) {
- StringRef Name = Label.getName();
- if (!Name.empty())
- addString(LabelDie, dwarf::DW_AT_name, Name);
- const auto *DILabel = Label.getLabel();
- addSourceLine(LabelDie, DILabel);
-}
-
/// Add a Dwarf expression attribute data and value.
void DwarfCompileUnit::addExpr(DIELoc &Die, dwarf::Form Form,
const MCExpr *Expr) {