From f4c339e04a33c85a40c8d0df692614f6d8f56a6a Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Tue, 29 Oct 2013 22:49:29 +0000 Subject: 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. llvm-svn: 193657 --- llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | 27 ++++++++---------------- 1 file changed, 9 insertions(+), 18 deletions(-) (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp') diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index 8f4b1965e7a..db8558cfeca 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/llvm/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; } -- cgit v1.2.3