From d6baff65f743816f121fc9cea3564d5ecea22a86 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Wed, 25 Jul 2018 22:03:35 +0000 Subject: [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 --- llvm/lib/CodeGen/GlobalMerge.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'llvm/lib/CodeGen/GlobalMerge.cpp') 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 MustKeepGlobalVariables; @@ -558,9 +558,9 @@ bool GlobalMerge::doMerge(const SmallVectorImpl &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) { -- cgit v1.2.3