summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/GlobalMerge.cpp
diff options
context:
space:
mode:
authorEli Friedman <efriedma@codeaurora.org>2018-07-25 22:03:35 +0000
committerEli Friedman <efriedma@codeaurora.org>2018-07-25 22:03:35 +0000
commitd6baff65f743816f121fc9cea3564d5ecea22a86 (patch)
tree0d282c40c168b338d7e448a0ceddc70f1acc2204 /llvm/lib/CodeGen/GlobalMerge.cpp
parent5a0a83daaf6b5c22decee929a7cbb2af68937d50 (diff)
downloadbcm5719-llvm-d6baff65f743816f121fc9cea3564d5ecea22a86.tar.gz
bcm5719-llvm-d6baff65f743816f121fc9cea3564d5ecea22a86.zip
[GlobalMerge] Handle llvm.compiler.used correctly.
Reuse the handling for llvm.used, and don't transform such globals. Fixes a failure on the asan buildbot caused by my previous commit. llvm-svn: 337973
Diffstat (limited to 'llvm/lib/CodeGen/GlobalMerge.cpp')
-rw-r--r--llvm/lib/CodeGen/GlobalMerge.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/GlobalMerge.cpp b/llvm/lib/CodeGen/GlobalMerge.cpp
index 3343b33d7fb..ca56f4e0c4f 100644
--- a/llvm/lib/CodeGen/GlobalMerge.cpp
+++ b/llvm/lib/CodeGen/GlobalMerge.cpp
@@ -177,7 +177,7 @@ namespace {
void setMustKeepGlobalVariables(Module &M);
/// Collect every variables marked as "used"
- void collectUsedGlobalVariables(Module &M);
+ void collectUsedGlobalVariables(Module &M, StringRef Name);
/// Keep track of the GlobalVariable that must not be merged away
SmallPtrSet<const GlobalVariable *, 16> MustKeepGlobalVariables;
@@ -558,9 +558,9 @@ bool GlobalMerge::doMerge(const SmallVectorImpl<GlobalVariable *> &Globals,
return Changed;
}
-void GlobalMerge::collectUsedGlobalVariables(Module &M) {
+void GlobalMerge::collectUsedGlobalVariables(Module &M, StringRef Name) {
// Extract global variables from llvm.used array
- const GlobalVariable *GV = M.getGlobalVariable("llvm.used");
+ const GlobalVariable *GV = M.getGlobalVariable(Name);
if (!GV || !GV->hasInitializer()) return;
// Should be an array of 'i8*'.
@@ -573,7 +573,8 @@ void GlobalMerge::collectUsedGlobalVariables(Module &M) {
}
void GlobalMerge::setMustKeepGlobalVariables(Module &M) {
- collectUsedGlobalVariables(M);
+ collectUsedGlobalVariables(M, "llvm.used");
+ collectUsedGlobalVariables(M, "llvm.compiler.used");
for (Function &F : M) {
for (BasicBlock &BB : F) {
OpenPOWER on IntegriCloud