summaryrefslogtreecommitdiff
path: root/lib/CodeGen/AsmPrinter
diff options
context:
space:
mode:
authorManman Ren <manman.ren@gmail.com>2013-10-29 22:49:29 +0000
committerManman Ren <manman.ren@gmail.com>2013-10-29 22:49:29 +0000
commitd498e5e960f237d3eb04ad7680bd093d1954c7fe (patch)
treee102ff8da43f1f3510c12177713e49505d49fd56 /lib/CodeGen/AsmPrinter
parentd1ea5928ddbd38e99507f7f18df8ec8a865c7799 (diff)
downloadllvm-d498e5e960f237d3eb04ad7680bd093d1954c7fe.tar.gz
llvm-d498e5e960f237d3eb04ad7680bd093d1954c7fe.tar.bz2
llvm-d498e5e960f237d3eb04ad7680bd093d1954c7fe.tar.xz
Debug Info: instead of calling addToContextOwner which constructs the context
after the DIE creation, we construct the context first. Ensure that we create the context before we create a type so that we can add the newly created type to the parent. Remove last use of addToContextOwner now that it's not needed. We use createAndAddDIE to wrap around "new DIE(". Now all shareable DIEs should be added to their parents right after the creation. Reviewed off-list by Eric, Thanks. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193657 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/AsmPrinter')
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp27
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfCompileUnit.h3
2 files changed, 9 insertions, 21 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index 8f4b1965e7..db8558cfec 100644
--- a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -826,34 +826,26 @@ DIE *CompileUnit::getOrCreateContextDIE(DIScope Context) {
return getDIE(Context);
}
-/// addToContextOwner - Add Die into the list of its context owner's children.
-void CompileUnit::addToContextOwner(DIE *Die, DIScope Context) {
- assert(!Die->getParent());
- if (DIE *ContextDIE = getOrCreateContextDIE(Context)) {
- if (Die->getParent()) {
- // While creating the context, if this is a type member, we will have
- // added the child to the context already.
- assert(Die->getParent() == ContextDIE);
- return;
- }
- ContextDIE->addChild(Die);
- } else
- addDie(Die);
-}
-
/// getOrCreateTypeDIE - Find existing DIE or create new DIE for the
/// given DIType.
DIE *CompileUnit::getOrCreateTypeDIE(const MDNode *TyNode) {
DIType Ty(TyNode);
if (!Ty.isType())
return NULL;
+
+ // Construct the context before querying for the existence of the DIE in case
+ // such construction creates the DIE.
+ DIE *ContextDIE = getOrCreateContextDIE(resolve(Ty.getContext()));
+ if (!ContextDIE)
+ ContextDIE = CUDie.get();
+
DIE *TyDIE = getDIE(Ty);
if (TyDIE)
return TyDIE;
// Create new type.
- TyDIE = new DIE(Ty.getTag());
- insertDIE(Ty, TyDIE);
+ TyDIE = createAndAddDIE(Ty.getTag(), *ContextDIE, Ty);
+
if (Ty.isBasicType())
constructTypeDIE(*TyDIE, DIBasicType(Ty));
else if (Ty.isCompositeType())
@@ -876,7 +868,6 @@ DIE *CompileUnit::getOrCreateTypeDIE(const MDNode *TyNode) {
addAccelType(Ty.getName(), std::make_pair(TyDIE, Flags));
}
- addToContextOwner(TyDIE, resolve(Ty.getContext()));
return TyDIE;
}
diff --git a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
index 79ef478ea3..1759ac4bda 100644
--- a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
+++ b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
@@ -280,9 +280,6 @@ public:
void addVariableAddress(const DbgVariable &DV, DIE *Die,
MachineLocation Location);
- /// addToContextOwner - Add Die into the list of its context owner's children.
- void addToContextOwner(DIE *Die, DIScope Context);
-
/// addType - Add a new type attribute to the specified entity. This takes
/// and attribute parameter because DW_AT_friend attributes are also
/// type references.