diff options
| author | David Blaikie <dblaikie@gmail.com> | 2014-04-30 21:29:41 +0000 |
|---|---|---|
| committer | David Blaikie <dblaikie@gmail.com> | 2014-04-30 21:29:41 +0000 |
| commit | 3b2a53a4370b898fdd6b6d4945b0d22df5d2c611 (patch) | |
| tree | 4f56e43dee500845f877d5a87c3cf2f67d2f35b2 /llvm/lib/CodeGen | |
| parent | c717e7803cbb0147e252a2ca31972c2bad4eac4a (diff) | |
| download | bcm5719-llvm-3b2a53a4370b898fdd6b6d4945b0d22df5d2c611.tar.gz bcm5719-llvm-3b2a53a4370b898fdd6b6d4945b0d22df5d2c611.zip | |
Emit DW_AT_object_pointer once, on the declaration, for each function.
This effectively reverts r164326, but adds some comments and
justification and ensures we /don't/ emit the DW_AT_object_pointer on
the (abstract and concrete) definitions. (while still preserving it on
standalone definitions involving ObjC Blocks)
This does increase the size of member function declarations from 7 to 11
bytes, unfortunately, but still seems like the Right Thing to do so that
callers that see only the declaration still have the information about
the object pointer. That said, I don't know what, if any, DWARF
consumers don't have a heuristic to guess this in the case of normal
C++ member functions - perhaps we can remove it entirely.
llvm-svn: 207705
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 13 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h | 2 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp | 9 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h | 2 |
4 files changed, 18 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index ac4eea4a50b..d9ef6c04285 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -548,11 +548,16 @@ DIE *DwarfDebug::createScopeChildrenDIE( } void DwarfDebug::createAndAddScopeChildren(DwarfCompileUnit &TheCU, - LexicalScope *Scope, DIE &ScopeDIE) { + LexicalScope *Scope, + DISubprogram Sub, DIE &ScopeDIE) { // We create children when the scope DIE is not null. SmallVector<std::unique_ptr<DIE>, 8> Children; if (DIE *ObjectPointer = createScopeChildrenDIE(TheCU, Scope, Children)) - TheCU.addDIEEntry(ScopeDIE, dwarf::DW_AT_object_pointer, *ObjectPointer); + // The declaration will have the object_pointer, otherwise put it on the + // definition. This happens with ObjC blocks that have object_pointer on + // non-member functions. + if (!Sub.getFunctionDeclaration()) + TheCU.addDIEEntry(ScopeDIE, dwarf::DW_AT_object_pointer, *ObjectPointer); // Add children for (auto &I : Children) @@ -571,7 +576,7 @@ void DwarfDebug::constructAbstractSubprogramScopeDIE(DwarfCompileUnit &TheCU, if (DIE *ScopeDIE = TheCU.getDIE(Sub)) { AbstractSPDies.insert(std::make_pair(Sub, ScopeDIE)); - createAndAddScopeChildren(TheCU, Scope, *ScopeDIE); + createAndAddScopeChildren(TheCU, Scope, Sub, *ScopeDIE); } } @@ -588,7 +593,7 @@ DIE &DwarfDebug::constructSubprogramScopeDIE(DwarfCompileUnit &TheCU, DIE &ScopeDIE = updateSubprogramScopeDIE(TheCU, Sub); - createAndAddScopeChildren(TheCU, Scope, ScopeDIE); + createAndAddScopeChildren(TheCU, Scope, Sub, ScopeDIE); return ScopeDIE; } diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h index d7359a3105e..16a314bdb32 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -371,7 +371,7 @@ class DwarfDebug : public AsmPrinterHandler { std::unique_ptr<DIE> constructScopeDIE(DwarfCompileUnit &TheCU, LexicalScope *Scope); void createAndAddScopeChildren(DwarfCompileUnit &TheCU, LexicalScope *Scope, - DIE &ScopeDIE); + DISubprogram Sub, DIE &ScopeDIE); /// \brief Construct a DIE for this abstract scope. void constructAbstractSubprogramScopeDIE(DwarfCompileUnit &TheCU, LexicalScope *Scope); diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index 4210a55459d..852eda14d86 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -1164,7 +1164,8 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, DIDerivedType DTy) { } /// constructSubprogramArguments - Construct function argument DIEs. -void DwarfUnit::constructSubprogramArguments(DIE &Buffer, DIArray Args) { +DIE *DwarfUnit::constructSubprogramArguments(DIE &Buffer, DIArray Args) { + DIE *ObjectPointer = nullptr; for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) { DIDescriptor Ty = Args.getElement(i); if (Ty.isUnspecifiedParameter()) { @@ -1175,8 +1176,11 @@ void DwarfUnit::constructSubprogramArguments(DIE &Buffer, DIArray Args) { addType(Arg, DIType(Ty)); if (DIType(Ty).isArtificial()) addFlag(Arg, dwarf::DW_AT_artificial); + if (DIType(Ty).isObjectPointer()) + ObjectPointer = &Arg; } } + return ObjectPointer; } /// constructTypeDIE - Construct type DIE from DICompositeType. @@ -1497,7 +1501,8 @@ DIE *DwarfUnit::getOrCreateSubprogramDIE(DISubprogram SP) { // Add arguments. Do not add arguments for subprogram definition. They will // be handled while processing variables. - constructSubprogramArguments(SPDie, Args); + if (DIE *ObjectPointer = constructSubprogramArguments(SPDie, Args)) + addDIEEntry(SPDie, dwarf::DW_AT_object_pointer, *ObjectPointer); } if (SP.isArtificial()) diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h index 5ce6595c88d..cf4bc991b25 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h @@ -416,7 +416,7 @@ public: bool isScopeAbstract); /// constructSubprogramArguments - Construct function argument DIEs. - void constructSubprogramArguments(DIE &Buffer, DIArray Args); + DIE *constructSubprogramArguments(DIE &Buffer, DIArray Args); /// Create a DIE with the given Tag, add the DIE to its parent, and /// call insertDIE if MD is not null. |

