summaryrefslogtreecommitdiffstats
path: root/llvm/lib/LTO
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2018-02-05 15:44:27 +0000
committerTeresa Johnson <tejohnson@google.com>2018-02-05 15:44:27 +0000
commit5a95c477305d0f25be289461eb3277f97b84ab08 (patch)
tree7b195f05af6cd1ce615fac0ff8a20694c0e262ba /llvm/lib/LTO
parent02947b71123a484bfebd060abd53bf4a65247a01 (diff)
downloadbcm5719-llvm-5a95c477305d0f25be289461eb3277f97b84ab08.tar.gz
bcm5719-llvm-5a95c477305d0f25be289461eb3277f97b84ab08.zip
[ThinLTO] Convert dead alias to declarations
Summary: This complements the fixes in r323633 and r324075 which drop the definitions of dead functions and variables, respectively. Fixes PR36208. Reviewers: grimar, rafael Subscribers: mehdi_amini, llvm-commits, inglorion Differential Revision: https://reviews.llvm.org/D42856 llvm-svn: 324242
Diffstat (limited to 'llvm/lib/LTO')
-rw-r--r--llvm/lib/LTO/LTOBackend.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp
index c9d842147f8..49c0c2e15b3 100644
--- a/llvm/lib/LTO/LTOBackend.cpp
+++ b/llvm/lib/LTO/LTOBackend.cpp
@@ -401,18 +401,14 @@ Error lto::backend(Config &C, AddStreamFn AddStream,
static void dropDeadSymbols(Module &Mod, const GVSummaryMapTy &DefinedGlobals,
const ModuleSummaryIndex &Index) {
- auto MaybeDrop = [&](GlobalValue &GV) {
+ std::vector<GlobalValue *> ReplacedGlobals;
+ for (auto &GV : Mod.global_values())
if (GlobalValueSummary *GVS = DefinedGlobals.lookup(GV.getGUID()))
- if (!Index.isGlobalValueLive(GVS))
- convertToDeclaration(GV);
- };
+ if (!Index.isGlobalValueLive(GVS) && !convertToDeclaration(GV))
+ ReplacedGlobals.push_back(&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);
+ for (GlobalValue *GV : ReplacedGlobals)
+ GV->eraseFromParent();
}
Error lto::thinBackend(Config &Conf, unsigned Task, AddStreamFn AddStream,
OpenPOWER on IntegriCloud