[llvm] r216845 - DebugInfo: Move argument creation up into the caller that's unambiguously handling the subprogram scope (replacing a conditional with an assertion in the process)
David Blaikie
dblaikie at gmail.com
Sun Aug 31 11:04:28 PDT 2014
Author: dblaikie
Date: Sun Aug 31 13:04:28 2014
New Revision: 216845
URL: http://llvm.org/viewvc/llvm-project?rev=216845&view=rev
Log:
DebugInfo: Move argument creation up into the caller that's unambiguously handling the subprogram scope (replacing a conditional with an assertion in the process)
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=216845&r1=216844&r2=216845&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Sun Aug 31 13:04:28 2014
@@ -458,26 +458,6 @@ DIE *DwarfDebug::createScopeChildrenDIE(
SmallVectorImpl<std::unique_ptr<DIE>> &Children) {
DIE *ObjectPointer = nullptr;
- // Collect arguments for current function.
- if (LScopes.isCurrentFunctionScope(Scope)) {
- for (DbgVariable *ArgDV : CurrentFnArguments)
- if (ArgDV)
- Children.push_back(
- constructVariableDIE(TheCU, *ArgDV, *Scope, ObjectPointer));
-
- // If this is a variadic function, add an unspecified parameter.
- DISubprogram SP(Scope->getScopeNode());
- DITypeArray FnArgs = SP.getType().getTypeArray();
- // If we have a single element of null, it is a function that returns void.
- // If we have more than one elements and the last one is null, it is a
- // variadic function.
- if (FnArgs.getNumElements() > 1 &&
- !FnArgs.getElement(FnArgs.getNumElements() - 1))
- Children.push_back(
- make_unique<DIE>(dwarf::DW_TAG_unspecified_parameters));
- }
-
- // Collect lexical scope children first.
for (DbgVariable *DV : ScopeVariables.lookup(Scope))
Children.push_back(constructVariableDIE(TheCU, *DV, *Scope, ObjectPointer));
@@ -487,16 +467,17 @@ DIE *DwarfDebug::createScopeChildrenDIE(
return ObjectPointer;
}
-void DwarfDebug::createAndAddScopeChildren(DwarfCompileUnit &TheCU,
+DIE *DwarfDebug::createAndAddScopeChildren(DwarfCompileUnit &TheCU,
LexicalScope *Scope, 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);
+ DIE *ObjectPointer = createScopeChildrenDIE(TheCU, Scope, Children);
// Add children
for (auto &I : Children)
ScopeDIE.addChild(std::move(I));
+
+ return ObjectPointer;
}
void DwarfDebug::constructAbstractSubprogramScopeDIE(DwarfCompileUnit &TheCU,
@@ -535,7 +516,8 @@ void DwarfDebug::constructAbstractSubpro
SPCU.applySubprogramAttributesToDefinition(SP, *AbsDef);
SPCU.addUInt(*AbsDef, dwarf::DW_AT_inline, None, dwarf::DW_INL_inlined);
- createAndAddScopeChildren(SPCU, Scope, *AbsDef);
+ if (DIE *ObjectPointer = createAndAddScopeChildren(SPCU, Scope, *AbsDef))
+ SPCU.addDIEEntry(*AbsDef, dwarf::DW_AT_object_pointer, *ObjectPointer);
}
DIE &DwarfDebug::constructSubprogramScopeDIE(DwarfCompileUnit &TheCU,
@@ -551,7 +533,33 @@ DIE &DwarfDebug::constructSubprogramScop
DIE &ScopeDIE = updateSubprogramScopeDIE(TheCU, Sub);
- createAndAddScopeChildren(TheCU, Scope, ScopeDIE);
+ // Collect arguments for current function.
+ assert(LScopes.isCurrentFunctionScope(Scope));
+ DIE *ObjectPointer = nullptr;
+ for (DbgVariable *ArgDV : CurrentFnArguments)
+ if (ArgDV)
+ ScopeDIE.addChild(
+ constructVariableDIE(TheCU, *ArgDV, *Scope, ObjectPointer));
+
+ // If this is a variadic function, add an unspecified parameter.
+ DITypeArray FnArgs = Sub.getType().getTypeArray();
+ // If we have a single element of null, it is a function that returns void.
+ // If we have more than one elements and the last one is null, it is a
+ // variadic function.
+ if (FnArgs.getNumElements() > 1 &&
+ !FnArgs.getElement(FnArgs.getNumElements() - 1))
+ ScopeDIE.addChild(make_unique<DIE>(dwarf::DW_TAG_unspecified_parameters));
+
+ // Collect lexical scope children first.
+ // ObjectPointer might be a local (non-argument) local variable if it's a
+ // block's synthetic this pointer.
+ if (DIE *BlockObjPtr = createAndAddScopeChildren(TheCU, Scope, ScopeDIE)) {
+ assert(!ObjectPointer && "multiple object pointers can't be described");
+ ObjectPointer = BlockObjPtr;
+ }
+
+ if (ObjectPointer)
+ TheCU.addDIEEntry(ScopeDIE, dwarf::DW_AT_object_pointer, *ObjectPointer);
return ScopeDIE;
}
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=216845&r1=216844&r2=216845&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Sun Aug 31 13:04:28 2014
@@ -379,7 +379,7 @@ class DwarfDebug : public AsmPrinterHand
/// \brief Construct a DIE for this scope.
std::unique_ptr<DIE> constructScopeDIE(DwarfCompileUnit &TheCU,
LexicalScope *Scope);
- void createAndAddScopeChildren(DwarfCompileUnit &TheCU, LexicalScope *Scope,
+ DIE *createAndAddScopeChildren(DwarfCompileUnit &TheCU, LexicalScope *Scope,
DIE &ScopeDIE);
/// \brief Construct a DIE for this abstract scope.
void constructAbstractSubprogramScopeDIE(DwarfCompileUnit &TheCU,
More information about the llvm-commits
mailing list