diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2016-09-13 01:12:59 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2016-09-13 01:12:59 +0000 |
commit | d4135bbc30de3d3dbd44d64d718fb2169f41bae0 (patch) | |
tree | 0b96e34c50822aed89a2272d9e9f3688bc3a0e46 /llvm/lib/Transforms/IPO/StripSymbols.cpp | |
parent | efc066758309683482edd289d82ec7670d38931f (diff) | |
download | bcm5719-llvm-d4135bbc30de3d3dbd44d64d718fb2169f41bae0.tar.gz bcm5719-llvm-d4135bbc30de3d3dbd44d64d718fb2169f41bae0.zip |
DebugInfo: New metadata representation for global variables.
This patch reverses the edge from DIGlobalVariable to GlobalVariable.
This will allow us to more easily preserve debug info metadata when
manipulating global variables.
Fixes PR30362. A program for upgrading test cases is attached to that
bug.
Differential Revision: http://reviews.llvm.org/D20147
llvm-svn: 281284
Diffstat (limited to 'llvm/lib/Transforms/IPO/StripSymbols.cpp')
-rw-r--r-- | llvm/lib/Transforms/IPO/StripSymbols.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/IPO/StripSymbols.cpp b/llvm/lib/Transforms/IPO/StripSymbols.cpp index fd250366cef..51c2103e0e5 100644 --- a/llvm/lib/Transforms/IPO/StripSymbols.cpp +++ b/llvm/lib/Transforms/IPO/StripSymbols.cpp @@ -312,13 +312,14 @@ bool StripDeadDebugInfo::runOnModule(Module &M) { // replace the current list of potentially dead global variables/functions // with the live list. SmallVector<Metadata *, 64> LiveGlobalVariables; - SmallVector<Metadata *, 64> LiveSubprograms; DenseSet<const MDNode *> VisitedSet; - std::set<DISubprogram *> LiveSPs; - for (Function &F : M) { - if (DISubprogram *SP = F.getSubprogram()) - LiveSPs.insert(SP); + std::set<DIGlobalVariable *> LiveGVs; + for (GlobalVariable &GV : M.globals()) { + SmallVector<DIGlobalVariable *, 1> DIs; + GV.getDebugInfo(DIs); + for (DIGlobalVariable *DI : DIs) + LiveGVs.insert(DI); } for (DICompileUnit *DIC : F.compile_units()) { @@ -329,9 +330,8 @@ bool StripDeadDebugInfo::runOnModule(Module &M) { if (!VisitedSet.insert(DIG).second) continue; - // If the global variable referenced by DIG is not null, the global - // variable is live. - if (DIG->getVariable()) + // If a global variable references DIG, the global variable is live. + if (LiveGVs.count(DIG)) LiveGlobalVariables.push_back(DIG); else GlobalVariableChange = true; @@ -345,7 +345,6 @@ bool StripDeadDebugInfo::runOnModule(Module &M) { } // Reset lists for the next iteration. - LiveSubprograms.clear(); LiveGlobalVariables.clear(); } |