summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2016-04-09 18:10:22 +0000
committerAdrian Prantl <aprantl@apple.com>2016-04-09 18:10:22 +0000
commit3891e9e859e76dec82f88a9ed902fe7e016147cd (patch)
treeda3080840db67a29d4270cced162335e3c3ea913 /llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
parent4abae4e0faea4930ca7d941358ba535835cba1c0 (diff)
downloadbcm5719-llvm-3891e9e859e76dec82f88a9ed902fe7e016147cd.tar.gz
bcm5719-llvm-3891e9e859e76dec82f88a9ed902fe7e016147cd.zip
Drop debug info for DISubprograms that are not referenced by anything
This patch drops the debug info for all DISubprograms that are (a) not attached to an llvm::Function and (b) not indirectly reachable via inline scopes from any surviving Function and (c) not reachable from a type (i.e.: member functions). Background: I'm currently working on a patch to reverse the pointers between DICompileUnit and DISubprogram (for more info check Duncan's RFC on lazy-loading of debug info metadata http://lists.llvm.org/pipermail/llvm-dev/2016-March/097419.html). The idea is to remove the list of subprograms from DICompileUnit and instead point to the owning compile unit from each DISubprogram. After doing this all DISubprograms fulfilling the above criteria will be implicitly dropped unless we go through an extra effort to preserve them. http://reviews.llvm.org/D18477 <rdar://problem/25256815> llvm-svn: 265876
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp37
1 files changed, 8 insertions, 29 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index d9d265ef2b9..9195ca310a2 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -526,32 +526,10 @@ void DwarfDebug::finishVariableDefinitions() {
void DwarfDebug::finishSubprogramDefinitions() {
for (const auto &P : SPMap)
- forBothCUs(*P.second, [&](DwarfCompileUnit &CU) {
- CU.finishSubprogramDefinition(cast<DISubprogram>(P.first));
- });
-}
-
-// Collect info for variables that were optimized out.
-void DwarfDebug::collectDeadVariables() {
- const Module *M = MMI->getModule();
-
- if (NamedMDNode *CU_Nodes = M->getNamedMetadata("llvm.dbg.cu")) {
- for (MDNode *N : CU_Nodes->operands()) {
- auto *TheCU = cast<DICompileUnit>(N);
- if (TheCU->getEmissionKind() == DICompileUnit::NoDebug)
- continue;
-
- // Construct subprogram DIE and add variables DIEs.
- DwarfCompileUnit *SPCU =
- static_cast<DwarfCompileUnit *>(CUMap.lookup(TheCU));
- assert(SPCU && "Unable to find Compile Unit!");
- for (auto *SP : TheCU->getSubprograms()) {
- if (ProcessedSPNodes.count(SP) != 0)
- continue;
- SPCU->collectDeadVariables(SP);
- }
- }
- }
+ if (ProcessedSPNodes.count(P.first))
+ forBothCUs(*P.second, [&](DwarfCompileUnit &CU) {
+ CU.finishSubprogramDefinition(cast<DISubprogram>(P.first));
+ });
}
void DwarfDebug::finalizeModuleInfo() {
@@ -561,9 +539,6 @@ void DwarfDebug::finalizeModuleInfo() {
finishVariableDefinitions();
- // Collect info for variables that were optimized out.
- collectDeadVariables();
-
// Handle anything that needs to be done on a per-unit basis after
// all other generation.
for (const auto &P : CUMap) {
@@ -1129,6 +1104,10 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {
PrevCU = nullptr;
CurFn = nullptr;
DebugHandlerBase::endFunction(MF);
+ // Mark functions with no debug info on any instructions, but a
+ // valid DISubprogram as processed.
+ if (auto *SP = MF->getFunction()->getSubprogram())
+ ProcessedSPNodes.insert(SP);
return;
}
OpenPOWER on IntegriCloud