diff options
| author | Adrian Prantl <aprantl@apple.com> | 2016-12-16 00:36:43 +0000 |
|---|---|---|
| committer | Adrian Prantl <aprantl@apple.com> | 2016-12-16 00:36:43 +0000 |
| commit | ce13935776a67c6bf7fffc3a0db76d27bfbd050a (patch) | |
| tree | 35634382729a60f610a4e72f5e511d75971f719a /llvm/lib/Transforms | |
| parent | 35bbcefb4be62f6f5a9630d8f0664c97e52b2b20 (diff) | |
| download | bcm5719-llvm-ce13935776a67c6bf7fffc3a0db76d27bfbd050a.tar.gz bcm5719-llvm-ce13935776a67c6bf7fffc3a0db76d27bfbd050a.zip | |
[IR] Remove the DIExpression field from DIGlobalVariable.
This patch implements PR31013 by introducing a
DIGlobalVariableExpression that holds a pair of DIGlobalVariable and
DIExpression.
Currently, DIGlobalVariables holds a DIExpression. This is not the
best way to model this:
(1) The DIGlobalVariable should describe the source level variable,
not how to get to its location.
(2) It makes it unsafe/hard to update the expressions when we call
replaceExpression on the DIGLobalVariable.
(3) It makes it impossible to represent a global variable that is in
more than one location (e.g., a variable with multiple
DW_OP_LLVM_fragment-s). We also moved away from attaching the
DIExpression to DILocalVariable for the same reasons.
<rdar://problem/29250149>
https://llvm.org/bugs/show_bug.cgi?id=31013
Differential Revision: https://reviews.llvm.org/D26769
llvm-svn: 289902
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/IPO/StripSymbols.cpp | 17 | ||||
| -rw-r--r-- | llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp | 2 |
2 files changed, 11 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/IPO/StripSymbols.cpp b/llvm/lib/Transforms/IPO/StripSymbols.cpp index 5cb8ff56584..8f6f161428e 100644 --- a/llvm/lib/Transforms/IPO/StripSymbols.cpp +++ b/llvm/lib/Transforms/IPO/StripSymbols.cpp @@ -313,20 +313,23 @@ bool StripDeadDebugInfo::runOnModule(Module &M) { // replace the current list of potentially dead global variables/functions // with the live list. SmallVector<Metadata *, 64> LiveGlobalVariables; - DenseSet<const MDNode *> VisitedSet; + DenseSet<DIGlobalVariableExpression *> VisitedSet; - std::set<DIGlobalVariable *> LiveGVs; + std::set<DIGlobalVariableExpression *> LiveGVs; for (GlobalVariable &GV : M.globals()) { - SmallVector<DIGlobalVariable *, 1> DIs; - GV.getDebugInfo(DIs); - for (DIGlobalVariable *DI : DIs) - LiveGVs.insert(DI); + SmallVector<DIGlobalVariableExpression *, 1> GVEs; + GV.getDebugInfo(GVEs); + for (auto *GVE : GVEs) + LiveGVs.insert(GVE); } for (DICompileUnit *DIC : F.compile_units()) { // Create our live global variable list. bool GlobalVariableChange = false; - for (DIGlobalVariable *DIG : DIC->getGlobalVariables()) { + for (auto *DIG : DIC->getGlobalVariables()) { + if (DIG->getExpression() && DIG->getExpression()->isConstant()) + LiveGVs.insert(DIG); + // Make sure we only visit each global variable only once. if (!VisitedSet.insert(DIG).second) continue; diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp index acc13aaeaf4..6a7cb0e45c6 100644 --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -1655,7 +1655,7 @@ bool AddressSanitizerModule::InstrumentGlobals(IRBuilder<> &IRB, Module &M) { // Transfer the debug info. The payload starts at offset zero so we can // copy the debug info over as is. - SmallVector<DIGlobalVariable *, 1> GVs; + SmallVector<DIGlobalVariableExpression *, 1> GVs; G->getDebugInfo(GVs); for (auto *GV : GVs) NewGlobal->addDebugInfo(GV); |

