summaryrefslogtreecommitdiffstats
path: root/llvm/lib/LTO
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2018-02-02 12:17:33 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2018-02-02 12:17:33 +0000
commit76c5fae2a00cf4fb9e662b4c1703412f8901cf43 (patch)
tree55c74207a292015bca7b7045d6e936ddbd76690a /llvm/lib/LTO
parent986d64ad7351c8abd2ca786ec8852c5916d69083 (diff)
downloadbcm5719-llvm-76c5fae2a00cf4fb9e662b4c1703412f8901cf43.tar.gz
bcm5719-llvm-76c5fae2a00cf4fb9e662b4c1703412f8901cf43.zip
[ThinLTO] - Fix for "ThinLTO inlines variables that should be discarded".
This fixes PR36187. Patch teaches ThinLTO to drop non-prevailing variables, just like we recently did for functions (in r323633). Differential revision: https://reviews.llvm.org/D42798 llvm-svn: 324075
Diffstat (limited to 'llvm/lib/LTO')
-rw-r--r--llvm/lib/LTO/LTOBackend.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp
index 1898d4bb25c..4595ea84b1e 100644
--- a/llvm/lib/LTO/LTOBackend.cpp
+++ b/llvm/lib/LTO/LTOBackend.cpp
@@ -401,13 +401,19 @@ Error lto::backend(Config &C, AddStreamFn AddStream,
static void dropDeadSymbols(Module &Mod, const GVSummaryMapTy &DefinedGlobals,
const ModuleSummaryIndex &Index) {
- for (auto &GV : Mod) {
+ auto MaybeDrop = [&](GlobalValue &GV) {
auto It = DefinedGlobals.find(GV.getGUID());
- if (It == DefinedGlobals.end())
- continue;
- if (!Index.isGlobalValueLive(It->second))
- convertToDeclaration(GV);
- }
+ if (It != DefinedGlobals.end())
+ if (!Index.isGlobalValueLive(It->second))
+ convertToDeclaration(GV);
+ };
+
+ // Process functions and global now.
+ // FIXME: add support for aliases (needs support in convertToDeclaration).
+ for (auto &GV : Mod)
+ MaybeDrop(GV);
+ for (auto &GV : Mod.globals())
+ MaybeDrop(GV);
}
Error lto::thinBackend(Config &Conf, unsigned Task, AddStreamFn AddStream,
OpenPOWER on IntegriCloud