diff options
| author | Stephen Hines <srhines@google.com> | 2013-05-02 16:19:29 -0700 |
|---|---|---|
| committer | Stephen Hines <srhines@google.com> | 2013-05-02 16:19:29 -0700 |
| commit | 38578c4919ea18ceb27e29988b2d857afe6215bf (patch) | |
| tree | 6718ee1e6a1a59f46b6c847439ebfcd291c1e393 /lib/Transforms/Scalar/GlobalMerge.cpp | |
| parent | ffb69c62ac54b0af5768ae9486b93b39a6c6b94c (diff) | |
| parent | a7a05ee70cb07f32996a0587a636b406c746b71b (diff) | |
| download | external_llvm-38578c4919ea18ceb27e29988b2d857afe6215bf.zip external_llvm-38578c4919ea18ceb27e29988b2d857afe6215bf.tar.gz external_llvm-38578c4919ea18ceb27e29988b2d857afe6215bf.tar.bz2 | |
Merge remote-tracking branch 'upstream/master' into merge-20130502
Conflicts:
lib/Support/Unix/Signals.inc
unittests/Transforms/Utils/Cloning.cpp
Change-Id: I027581a4390ec3ce4cd8d33da8b5f4c0c7d372c8
Diffstat (limited to 'lib/Transforms/Scalar/GlobalMerge.cpp')
| -rw-r--r-- | lib/Transforms/Scalar/GlobalMerge.cpp | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/lib/Transforms/Scalar/GlobalMerge.cpp b/lib/Transforms/Scalar/GlobalMerge.cpp index 14e463a..4796eb2 100644 --- a/lib/Transforms/Scalar/GlobalMerge.cpp +++ b/lib/Transforms/Scalar/GlobalMerge.cpp @@ -61,10 +61,8 @@ #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/Function.h" #include "llvm/IR/GlobalVariable.h" -#include "llvm/IR/InlineAsm.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/Intrinsics.h" -#include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/Module.h" #include "llvm/Pass.h" #include "llvm/Support/CommandLine.h" @@ -101,7 +99,7 @@ namespace { /// Collect every variables marked as "used" void collectUsedGlobalVariables(Module &M); - /// Keep track of the GlobalVariable that are marked as "used" + /// Keep track of the GlobalVariable that must not be merged away SmallPtrSet<const GlobalVariable *, 16> MustKeepGlobalVariables; public: @@ -113,6 +111,7 @@ namespace { virtual bool doInitialization(Module &M); virtual bool runOnFunction(Function &F); + virtual bool doFinalization(Module &M); const char *getPassName() const { return "Merge internal globals"; @@ -201,9 +200,8 @@ void GlobalMerge::collectUsedGlobalVariables(Module &M) { if (!GV || !GV->hasInitializer()) return; // Should be an array of 'i8*'. - const ConstantArray *InitList = dyn_cast<ConstantArray>(GV->getInitializer()); - if (InitList == 0) return; - + const ConstantArray *InitList = cast<ConstantArray>(GV->getInitializer()); + for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i) if (const GlobalVariable *G = dyn_cast<GlobalVariable>(InitList->getOperand(i)->stripPointerCasts())) @@ -211,9 +209,6 @@ void GlobalMerge::collectUsedGlobalVariables(Module &M) { } void GlobalMerge::setMustKeepGlobalVariables(Module &M) { - // If we already processed a Module, UsedGlobalVariables may have been - // populated. Reset the information for this module. - MustKeepGlobalVariables.clear(); collectUsedGlobalVariables(M); for (Module::iterator IFn = M.begin(), IEndFn = M.end(); IFn != IEndFn; @@ -268,8 +263,6 @@ bool GlobalMerge::doInitialization(Module &M) { continue; // Ignore all "required" globals: - // - the ones used for EH - // - the ones marked with "used" attribute if (isMustKeepGlobalVariable(I)) continue; @@ -307,6 +300,11 @@ bool GlobalMerge::runOnFunction(Function &F) { return false; } +bool GlobalMerge::doFinalization(Module &M) { + MustKeepGlobalVariables.clear(); + return false; +} + Pass *llvm::createGlobalMergePass(const TargetLowering *tli) { return new GlobalMerge(tli); } |
