diff options
author | Manman Ren <manman.ren@gmail.com> | 2013-10-01 19:52:23 +0000 |
---|---|---|
committer | Manman Ren <manman.ren@gmail.com> | 2013-10-01 19:52:23 +0000 |
commit | 8990d7ee842a2f4014046a7dc7eb4e1bdb9ef4c2 (patch) | |
tree | 66258883a93697129b5f4afacace222c0ab471ab /llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | |
parent | a4da6fb53577d16b61fab965284dbf4cb5a31ff2 (diff) | |
download | bcm5719-llvm-8990d7ee842a2f4014046a7dc7eb4e1bdb9ef4c2.tar.gz bcm5719-llvm-8990d7ee842a2f4014046a7dc7eb4e1bdb9ef4c2.zip |
Debug Info: remove duplication of DIEs when a DIE is part of the type system
and it is shared across CUs.
We add a few maps in DwarfDebug to map MDNodes for the type system to the
corresponding DIEs: MDTypeNodeToDieMap, MDSPNodeToDieMap, and
MDStaticMemberNodeToDieMap. These DIEs can be shared across CUs, that is why we
keep the maps in DwarfDebug instead of CompileUnit.
Sometimes, when we try to add an attribute to a DIE, the DIE is not yet added
to its owner yet, so we don't know whether we should use ref_addr or ref4.
We create a worklist that will be processed during finalization to add
attributes with the correct form (ref_addr or ref4).
We add addDIEEntry to DwarfDebug to be a wrapper around DIE->addValue. It checks
whether we know the correct form, if not, we update the worklist
(DIEEntryWorklist).
A testing case is added to show that we only create a single DIE for a type
MDNode and we use ref_addr to refer to the type DIE.
llvm-svn: 191792
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index d3d8251bb2f..e5761ea475d 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -242,7 +242,7 @@ void CompileUnit::addDelta(DIE *Die, uint16_t Attribute, uint16_t Form, /// void CompileUnit::addDIEEntry(DIE *Die, uint16_t Attribute, uint16_t Form, DIE *Entry) { - Die->addValue(Attribute, Form, createDIEEntry(Entry)); + DD->addDIEEntry(Die, Attribute, Form, createDIEEntry(Entry)); } /// addBlock - Add block data. @@ -784,13 +784,13 @@ DIE *CompileUnit::getOrCreateTypeDIE(const MDNode *TyNode) { DIType Ty(TyNode); if (!Ty.isType()) return NULL; - DIE *TyDIE = getDIE(Ty); + DIE *TyDIE = DD->getTypeDIE(Ty); if (TyDIE) return TyDIE; // Create new type. TyDIE = new DIE(dwarf::DW_TAG_base_type); - insertDIE(Ty, TyDIE); + DD->insertTypeDIE(Ty, TyDIE); if (Ty.isBasicType()) constructTypeDIE(*TyDIE, DIBasicType(Ty)); else if (Ty.isCompositeType()) @@ -826,7 +826,7 @@ void CompileUnit::addType(DIE *Entity, DIType Ty, uint16_t Attribute) { DIEEntry *Entry = getDIEEntry(Ty); // If it exists then use the existing value. if (Entry) { - Entity->addValue(Attribute, dwarf::DW_FORM_ref4, Entry); + DD->addDIEEntry(Entity, Attribute, dwarf::DW_FORM_ref4, Entry); return; } @@ -836,7 +836,7 @@ void CompileUnit::addType(DIE *Entity, DIType Ty, uint16_t Attribute) { // Set up proxy. Entry = createDIEEntry(Buffer); insertDIEEntry(Ty, Entry); - Entity->addValue(Attribute, dwarf::DW_FORM_ref4, Entry); + DD->addDIEEntry(Entity, Attribute, dwarf::DW_FORM_ref4, Entry); // If this is a complete composite type then include it in the // list of global types. @@ -1268,14 +1268,14 @@ DIE *CompileUnit::getOrCreateNameSpace(DINameSpace NS) { /// getOrCreateSubprogramDIE - Create new DIE using SP. DIE *CompileUnit::getOrCreateSubprogramDIE(DISubprogram SP) { - DIE *SPDie = getDIE(SP); + DIE *SPDie = DD->getSPDIE(SP); if (SPDie) return SPDie; SPDie = new DIE(dwarf::DW_TAG_subprogram); // DW_TAG_inlined_subroutine may refer to this DIE. - insertDIE(SP, SPDie); + DD->insertSPDIE(SP, SPDie); DISubprogram SPDecl = SP.getFunctionDeclaration(); DIE *DeclDie = NULL; @@ -1422,7 +1422,7 @@ void CompileUnit::createGlobalVariableDIE(const MDNode *N) { // But that class might not exist in the DWARF yet. // Creating the class will create the static member decl DIE. getOrCreateContextDIE(DD->resolve(SDMDecl.getContext())); - VariableDIE = getDIE(SDMDecl); + VariableDIE = DD->getStaticMemberDIE(SDMDecl); assert(VariableDIE && "Static member decl has no context?"); IsStaticMember = true; } @@ -1616,7 +1616,7 @@ void CompileUnit::constructContainingTypeDIEs() { DIE *SPDie = CI->first; const MDNode *N = CI->second; if (!N) continue; - DIE *NDie = getDIE(N); + DIE *NDie = DD->getTypeDIE(N); if (!NDie) continue; addDIEEntry(SPDie, dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4, NDie); } @@ -1819,6 +1819,6 @@ DIE *CompileUnit::createStaticMemberDIE(const DIDerivedType DT) { if (const ConstantFP *CFP = dyn_cast_or_null<ConstantFP>(DT.getConstant())) addConstantFPValue(StaticMemberDIE, CFP); - insertDIE(DT, StaticMemberDIE); + DD->insertStaticMemberDIE(DT, StaticMemberDIE); return StaticMemberDIE; } |