diff options
author | David Blaikie <dblaikie@gmail.com> | 2014-09-19 17:03:16 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2014-09-19 17:03:16 +0000 |
commit | 3a7ce252ccfe74321e54289322dfc2a1838d5fba (patch) | |
tree | 6909c9183ba5628dd5607a85bd9115d1c8849024 /llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | |
parent | 6ad58095c7eb8b9715db3623442e924d6e2900bc (diff) | |
download | bcm5719-llvm-3a7ce252ccfe74321e54289322dfc2a1838d5fba.tar.gz bcm5719-llvm-3a7ce252ccfe74321e54289322dfc2a1838d5fba.zip |
Omit DW_TAG_subprograms for subprograms without inlined subroutines when producing -gmlt data
To reduce the size of -gmlt data, skip the subprograms without any
inlined subroutines. Since we've now got the ability to make these
determinations in the backend (funnily enough - we added the flag so we
wouldn't produce ranges under -gmlt, but with this change we use the
flag, but go back to producing ranges under -gmlt).
Instead, just produce CU ranges to inform the consumer which parts of
the code are described by this CU's line table. Tools could inspect the
line table directly to compute the range, but the CU ranges only seem to
be about 0.5% of object/executable size, so I'm not too worried about
teaching llvm-symbolizer that trick just yet - it's certainly a possible
piece of future work.
Update an llvm-symbolizer test just to demonstrate that this schema is
acceptable there (if it wasn't, the compiler-rt tests would catch this,
but good to have an in-llvm-tree test for llvm-symbolizer's behavior
here)
Building the clang binary with -gmlt with this patch reduces the total
size of object files by 5.1% (5.56% without ranges) without compression
and the executable by 4.37% (4.75% without ranges).
llvm-svn: 218129
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 742646b0555..7cd06931249 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -856,12 +856,14 @@ void DwarfDebug::finishSubprogramDefinitions() { // If this subprogram has an abstract definition, reference that SPCU->addDIEEntry(*D, dwarf::DW_AT_abstract_origin, *AbsSPDIE); } else { - if (!D) + if (!D && TheCU.getEmissionKind() != DIBuilder::LineTablesOnly) // Lazily construct the subprogram if we didn't see either concrete or - // inlined versions during codegen. + // inlined versions during codegen. (except in -gmlt ^ where we want + // to omit these entirely) D = SPCU->getOrCreateSubprogramDIE(SP); - // And attach the attributes - SPCU->applySubprogramAttributesToDefinition(SP, *D); + if (D) + // And attach the attributes + SPCU->applySubprogramAttributesToDefinition(SP, *D); } } } @@ -1690,6 +1692,24 @@ void DwarfDebug::endFunction(const MachineFunction *MF) { LexicalScope *FnScope = LScopes.getCurrentFunctionScope(); DwarfCompileUnit &TheCU = *SPMap.lookup(FnScope->getScopeNode()); + // Add the range of this function to the list of ranges for the CU. + TheCU.addRange(RangeSpan(FunctionBeginSym, FunctionEndSym)); + + // Under -gmlt, skip building the subprogram if there are no inlined + // subroutines inside it. + if (TheCU.getCUNode().getEmissionKind() == DIBuilder::LineTablesOnly && + LScopes.getAbstractScopesList().empty()) { + assert(ScopeVariables.empty()); + assert(CurrentFnArguments.empty()); + assert(DbgValues.empty()); + assert(AbstractVariables.empty()); + LabelsBeforeInsn.clear(); + LabelsAfterInsn.clear(); + PrevLabel = nullptr; + CurFn = nullptr; + return; + } + // Construct abstract scopes. for (LexicalScope *AScope : LScopes.getAbstractScopesList()) { DISubprogram SP(AScope->getScopeNode()); @@ -1710,10 +1730,6 @@ void DwarfDebug::endFunction(const MachineFunction *MF) { if (!CurFn->getTarget().Options.DisableFramePointerElim(*CurFn)) TheCU.addFlag(CurFnDIE, dwarf::DW_AT_APPLE_omit_frame_ptr); - // Add the range of this function to the list of ranges for the CU. - RangeSpan Span(FunctionBeginSym, FunctionEndSym); - TheCU.addRange(std::move(Span)); - // Clear debug info // Ownership of DbgVariables is a bit subtle - ScopeVariables owns all the // DbgVariables except those that are also in AbstractVariables (since they |