DebugInfo: Reference abstract definitions from variables in concrete definitions that preceed their first inline definition.

Rather than relying on abstract variables looked up at the time the
concrete variable is created, look them up at the end of the module to
ensure they're referenced even if they're created after the concrete
definition. This completes/matches the work done in r209677 to handle
this for the subprograms themselves.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210946 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Blaikie 2014-06-13 22:35:44 +00:00
parent 869d3efac9
commit f154f3b592
3 changed files with 11 additions and 7 deletions

View File

@ -791,7 +791,7 @@ void DwarfDebug::finishVariableDefinitions() {
// DIE::getUnit isn't simple - it walks parent pointers, etc. // DIE::getUnit isn't simple - it walks parent pointers, etc.
DwarfCompileUnit *Unit = lookupUnit(VariableDie->getUnit()); DwarfCompileUnit *Unit = lookupUnit(VariableDie->getUnit());
assert(Unit); assert(Unit);
DbgVariable *AbsVar = Var->getAbstractVariable(); DbgVariable *AbsVar = getExistingAbstractVariable(Var->getVariable());
if (AbsVar && AbsVar->getDIE()) { if (AbsVar && AbsVar->getDIE()) {
Unit->addDIEEntry(*VariableDie, dwarf::DW_AT_abstract_origin, Unit->addDIEEntry(*VariableDie, dwarf::DW_AT_abstract_origin,
*AbsVar->getDIE()); *AbsVar->getDIE());
@ -1081,6 +1081,11 @@ DbgVariable *DwarfDebug::getExistingAbstractVariable(const DIVariable &DV,
return nullptr; return nullptr;
} }
DbgVariable *DwarfDebug::getExistingAbstractVariable(const DIVariable &DV) {
DIVariable Cleansed;
return getExistingAbstractVariable(DV, Cleansed);
}
DbgVariable *DwarfDebug::createAbstractVariable(DIVariable &Var, DbgVariable *DwarfDebug::createAbstractVariable(DIVariable &Var,
LexicalScope *Scope) { LexicalScope *Scope) {
auto AbsDbgVariable = make_unique<DbgVariable>(Var, nullptr, this); auto AbsDbgVariable = make_unique<DbgVariable>(Var, nullptr, this);

View File

@ -346,6 +346,7 @@ class DwarfDebug : public AsmPrinterHandler {
/// \brief Find abstract variable associated with Var. /// \brief Find abstract variable associated with Var.
DbgVariable *getExistingAbstractVariable(const DIVariable &DV, DbgVariable *getExistingAbstractVariable(const DIVariable &DV,
DIVariable &Cleansed); DIVariable &Cleansed);
DbgVariable *getExistingAbstractVariable(const DIVariable &DV);
DbgVariable *createAbstractVariable(DIVariable &DV, LexicalScope *Scope); DbgVariable *createAbstractVariable(DIVariable &DV, LexicalScope *Scope);
DbgVariable *getOrCreateAbstractVariable(DIVariable &Var, DbgVariable *getOrCreateAbstractVariable(DIVariable &Var,
const MDNode *Scope); const MDNode *Scope);

View File

@ -7,22 +7,20 @@
; CHECK: DW_TAG_subprogram ; CHECK: DW_TAG_subprogram
; CHECK: DW_AT_abstract_origin {{.*}}{[[ABS:.*]]} ; CHECK: DW_AT_abstract_origin {{.*}}{[[ABS:.*]]}
; FIXME: An out of line definition preceding an inline usage doesn't properly
; reference abstract variables.
; CHECK: DW_TAG_formal_parameter ; CHECK: DW_TAG_formal_parameter
; CHECK-NOT: DW_TAG ; CHECK-NOT: DW_TAG
; CHECK: DW_AT_name {{.*}} "sp" ; CHECK: DW_AT_abstract_origin {{.*}}{[[ABS_SP:.*]]}
; CHECK: DW_TAG_formal_parameter ; CHECK: DW_TAG_formal_parameter
; CHECK-NOT: DW_TAG ; CHECK-NOT: DW_TAG
; CHECK: DW_AT_name {{.*}} "nums" ; CHECK: DW_AT_abstract_origin {{.*}}{[[ABS_NUMS:.*]]}
; CHECK: [[ABS]]: DW_TAG_subprogram ; CHECK: [[ABS]]: DW_TAG_subprogram
; CHECK-NOT: DW_TAG ; CHECK-NOT: DW_TAG
; CHECK: DW_AT_name {{.*}} "foo" ; CHECK: DW_AT_name {{.*}} "foo"
; CHECK: [[ABS_SP:.*]]: DW_TAG_formal_parameter ; CHECK: [[ABS_SP]]: DW_TAG_formal_parameter
; CHECK-NOT: DW_TAG ; CHECK-NOT: DW_TAG
; CHECK: DW_AT_name {{.*}} "sp" ; CHECK: DW_AT_name {{.*}} "sp"
; CHECK: [[ABS_NUMS:.*]]: DW_TAG_formal_parameter ; CHECK: [[ABS_NUMS]]: DW_TAG_formal_parameter
; CHECK-NOT: DW_TAG ; CHECK-NOT: DW_TAG
; CHECK: DW_AT_name {{.*}} "nums" ; CHECK: DW_AT_name {{.*}} "nums"