diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 1eb88b9178d4..77bb77d4a5fd 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -791,7 +791,7 @@ void DwarfDebug::finishVariableDefinitions() { // DIE::getUnit isn't simple - it walks parent pointers, etc. DwarfCompileUnit *Unit = lookupUnit(VariableDie->getUnit()); assert(Unit); - DbgVariable *AbsVar = Var->getAbstractVariable(); + DbgVariable *AbsVar = getExistingAbstractVariable(Var->getVariable()); if (AbsVar && AbsVar->getDIE()) { Unit->addDIEEntry(*VariableDie, dwarf::DW_AT_abstract_origin, *AbsVar->getDIE()); @@ -1081,6 +1081,11 @@ DbgVariable *DwarfDebug::getExistingAbstractVariable(const DIVariable &DV, return nullptr; } +DbgVariable *DwarfDebug::getExistingAbstractVariable(const DIVariable &DV) { + DIVariable Cleansed; + return getExistingAbstractVariable(DV, Cleansed); +} + DbgVariable *DwarfDebug::createAbstractVariable(DIVariable &Var, LexicalScope *Scope) { auto AbsDbgVariable = make_unique(Var, nullptr, this); diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h index 88b8a674b3e1..8445b74798f5 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -346,6 +346,7 @@ class DwarfDebug : public AsmPrinterHandler { /// \brief Find abstract variable associated with Var. DbgVariable *getExistingAbstractVariable(const DIVariable &DV, DIVariable &Cleansed); + DbgVariable *getExistingAbstractVariable(const DIVariable &DV); DbgVariable *createAbstractVariable(DIVariable &DV, LexicalScope *Scope); DbgVariable *getOrCreateAbstractVariable(DIVariable &Var, const MDNode *Scope); diff --git a/llvm/test/DebugInfo/X86/dbg-value-inlined-parameter.ll b/llvm/test/DebugInfo/X86/dbg-value-inlined-parameter.ll index 2d3cf6e68072..4d18f7dc3063 100644 --- a/llvm/test/DebugInfo/X86/dbg-value-inlined-parameter.ll +++ b/llvm/test/DebugInfo/X86/dbg-value-inlined-parameter.ll @@ -7,22 +7,20 @@ ; CHECK: DW_TAG_subprogram ; 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-NOT: DW_TAG -; CHECK: DW_AT_name {{.*}} "sp" +; CHECK: DW_AT_abstract_origin {{.*}}{[[ABS_SP:.*]]} ; CHECK: DW_TAG_formal_parameter ; CHECK-NOT: DW_TAG -; CHECK: DW_AT_name {{.*}} "nums" +; CHECK: DW_AT_abstract_origin {{.*}}{[[ABS_NUMS:.*]]} ; CHECK: [[ABS]]: DW_TAG_subprogram ; CHECK-NOT: DW_TAG ; CHECK: DW_AT_name {{.*}} "foo" -; CHECK: [[ABS_SP:.*]]: DW_TAG_formal_parameter +; CHECK: [[ABS_SP]]: DW_TAG_formal_parameter ; CHECK-NOT: DW_TAG ; CHECK: DW_AT_name {{.*}} "sp" -; CHECK: [[ABS_NUMS:.*]]: DW_TAG_formal_parameter +; CHECK: [[ABS_NUMS]]: DW_TAG_formal_parameter ; CHECK-NOT: DW_TAG ; CHECK: DW_AT_name {{.*}} "nums"