From 3a443c29b9102ce728fc79acd76c731e5a0197f8 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Tue, 4 Nov 2014 22:12:25 +0000 Subject: Provide gmlt-like inline scope information in the skeleton CU to facilitate symbolication without needing the .dwo files Clang -gsplit-dwarf self-host -O0, binary increases by 0.0005%, -O2, binary increases by 25%. A large binary inside Google, split-dwarf, -O0, and other internal flags (GDB index, etc) increases by 1.8%, optimized build is 35%. The size impact may be somewhat greater in .o files (I haven't measured that much - since the linked executable -O0 numbers seemed low enough) due to relocations. These relocations could be removed if we taught the llvm-symbolizer to handle indexed addressing in the .o file (GDB can't cope with this just yet, but GDB won't be reading this info anyway). Also debug_ranges could be shared between .o and .dwo, though ideally debug_ranges would get a schema that could used index(+offset) addressing, and move to the .dwo file, then we'd be back to sharing addresses in the address pool again. But for now, these sizes seem small enough to go ahead with this. Verified that no other DW_TAGs are produced into the .o file other than subprograms and inlined_subroutines. llvm-svn: 221306 --- llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp | 39 ++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 14 deletions(-) (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp') diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index 1793757afcf..919d9d27480 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -1233,20 +1233,23 @@ DIE *DwarfUnit::getOrCreateNameSpace(DINameSpace NS) { } /// getOrCreateSubprogramDIE - Create new DIE using SP. -DIE *DwarfUnit::getOrCreateSubprogramDIE(DISubprogram SP) { +DIE *DwarfUnit::getOrCreateSubprogramDIE(DISubprogram SP, bool Minimal) { // Construct the context before querying for the existence of the DIE in case // such construction creates the DIE (as is the case for member function // declarations). - DIE *ContextDIE = getOrCreateContextDIE(resolve(SP.getContext())); + DIE *ContextDIE = + Minimal ? &getUnitDie() : getOrCreateContextDIE(resolve(SP.getContext())); if (DIE *SPDie = getDIE(SP)) return SPDie; if (DISubprogram SPDecl = SP.getFunctionDeclaration()) { - // Add subprogram definitions to the CU die directly. - ContextDIE = &getUnitDie(); - // Build the decl now to ensure it precedes the definition. - getOrCreateSubprogramDIE(SPDecl); + if (!Minimal) { + // Add subprogram definitions to the CU die directly. + ContextDIE = &getUnitDie(); + // Build the decl now to ensure it precedes the definition. + getOrCreateSubprogramDIE(SPDecl); + } } // DW_TAG_inlined_subroutine may refer to this DIE. @@ -1261,8 +1264,8 @@ DIE *DwarfUnit::getOrCreateSubprogramDIE(DISubprogram SP) { return &SPDie; } -void DwarfUnit::applySubprogramAttributes(DISubprogram SP, DIE &SPDie, - bool Minimal) { +bool DwarfUnit::applySubprogramDefinitionAttributes(DISubprogram SP, + DIE &SPDie) { DIE *DeclDie = nullptr; StringRef DeclLinkageName; if (DISubprogram SPDecl = SP.getFunctionDeclaration()) { @@ -1285,12 +1288,20 @@ void DwarfUnit::applySubprogramAttributes(DISubprogram SP, DIE &SPDie, addString(SPDie, dwarf::DW_AT_MIPS_linkage_name, GlobalValue::getRealLinkageName(LinkageName)); - if (DeclDie) { - // Refer to the function declaration where all the other attributes will be - // found. - addDIEEntry(SPDie, dwarf::DW_AT_specification, *DeclDie); - return; - } + if (!DeclDie) + return false; + + // Refer to the function declaration where all the other attributes will be + // found. + addDIEEntry(SPDie, dwarf::DW_AT_specification, *DeclDie); + return true; +} + +void DwarfUnit::applySubprogramAttributes(DISubprogram SP, DIE &SPDie, + bool Minimal) { + if (!Minimal) + if (applySubprogramDefinitionAttributes(SP, SPDie)) + return; // Constructors and operators for anonymous aggregates do not have names. if (!SP.getName().empty()) -- cgit v1.2.3