summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2017-07-28 03:06:25 +0000
committerDavid Blaikie <dblaikie@gmail.com>2017-07-28 03:06:25 +0000
commit89daf77a110dc19a05a83273f73d7db790b06b2b (patch)
tree6a4fa6f319d284dd09ddef1357a5d02dfe24c204 /llvm/lib
parent01cb947abb9bae5b6cb9f01a58490ece36fbdf70 (diff)
downloadbcm5719-llvm-89daf77a110dc19a05a83273f73d7db790b06b2b.tar.gz
bcm5719-llvm-89daf77a110dc19a05a83273f73d7db790b06b2b.zip
DebugInfo: Consider a CU containing only local imported entities to be 'empty'
This can come up in ThinLTO & wastes space & makes degenerate IR. As per the added FIXME, ultimately, local imported entities should hang off the function and that way the imported entity list on the CU can be tested for emptiness like all the other CU lists. (function-attached local imported entities are probably also the best path forward for fixing how imported entities are handled both in cross-module use (currently, while ThinLTO preserves the imported entities, they would not get used at the imported inlined location - only in the abstract origin that appears in the partial CU created by the import (which isn't emitted under Fission due to cross-CU limitations there)) and to reduce the number of points where imported entities are emitted (they're currently emitted into every inlined instance, concrete instance, and abstract origin - they should only go in teh abstract origin if there is one, otherwise in the concrete instance - but this requires lots of delayed handling and wiring up, same as abstract variables & subprograms)) llvm-svn: 309354
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 3fa00e50c5c..ed1ada62c73 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -428,6 +428,9 @@ DwarfDebug::getOrCreateDwarfCompileUnit(const DICompileUnit *DIUnit) {
Asm->TM.Options.MCOptions.SplitDwarfFile);
}
+ for (auto *IE : DIUnit->getImportedEntities())
+ NewCU.addImportedEntity(IE);
+
// LTO with assembly output shares a single line table amongst multiple CUs.
// To avoid the compilation directory being ambiguous, let the line table
// explicitly describe the directory of all files, never relying on the
@@ -522,14 +525,6 @@ sortGlobalExprs(SmallVectorImpl<DwarfCompileUnit::GlobalExpr> &GVEs) {
return GVEs;
}
-static bool isEmptyCU(DICompileUnit *CUNode) {
- return CUNode->getEnumTypes().empty() &&
- CUNode->getRetainedTypes().empty() &&
- CUNode->getGlobalVariables().empty() &&
- CUNode->getImportedEntities().empty() &&
- CUNode->getMacros().empty();
-}
-
// Emit all Dwarf sections that should come prior to the content. Create
// global DIEs and emit initial debug info sections. This is invoked by
// the target AsmPrinter.
@@ -556,12 +551,20 @@ void DwarfDebug::beginModule() {
}
for (DICompileUnit *CUNode : M->debug_compile_units()) {
- if (isEmptyCU(CUNode))
+ // FIXME: Move local imported entities into a list attached to the
+ // subprogram, then this search won't be needed and a
+ // getImportedEntities().empty() test should go below with the rest.
+ bool HasNonLocalImportedEntities = llvm::any_of(
+ CUNode->getImportedEntities(), [](const DIImportedEntity *IE) {
+ return !isa<DILocalScope>(IE->getScope());
+ });
+
+ if (!HasNonLocalImportedEntities && CUNode->getEnumTypes().empty() &&
+ CUNode->getRetainedTypes().empty() &&
+ CUNode->getGlobalVariables().empty() && CUNode->getMacros().empty())
continue;
DwarfCompileUnit &CU = getOrCreateDwarfCompileUnit(CUNode);
- for (auto *IE : CUNode->getImportedEntities())
- CU.addImportedEntity(IE);
// Global Variables.
for (auto *GVE : CUNode->getGlobalVariables())
OpenPOWER on IntegriCloud