From d4135bbc30de3d3dbd44d64d718fb2169f41bae0 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Tue, 13 Sep 2016 01:12:59 +0000 Subject: 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 --- llvm/lib/Transforms/IPO/StripSymbols.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'llvm/lib/Transforms/IPO/StripSymbols.cpp') 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 LiveGlobalVariables; - SmallVector LiveSubprograms; DenseSet VisitedSet; - std::set LiveSPs; - for (Function &F : M) { - if (DISubprogram *SP = F.getSubprogram()) - LiveSPs.insert(SP); + std::set LiveGVs; + for (GlobalVariable &GV : M.globals()) { + SmallVector 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(); } -- cgit v1.2.3