diff options
| author | Oliver Stannard <oliver.stannard@arm.com> | 2015-10-12 13:20:52 +0000 |
|---|---|---|
| committer | Oliver Stannard <oliver.stannard@arm.com> | 2015-10-12 13:20:52 +0000 |
| commit | 939724cd020b6172435a207e0e4d59dcab90048b (patch) | |
| tree | d6aec435ba56610a4cdb2dd29b1917b153316bd5 /llvm/lib/Transforms/Utils | |
| parent | 20c1971db35ad44ccfb344525e9d1dc761522417 (diff) | |
| download | bcm5719-llvm-939724cd020b6172435a207e0e4d59dcab90048b.tar.gz bcm5719-llvm-939724cd020b6172435a207e0e4d59dcab90048b.zip | |
GlobalOpt does not treat externally_initialized globals correctly
GlobalOpt currently merges stores into the initialisers of internal,
externally_initialized globals, but should not do so as the value of the global
may change between the initialiser and any code in the module being run.
llvm-svn: 250035
Diffstat (limited to 'llvm/lib/Transforms/Utils')
| -rw-r--r-- | llvm/lib/Transforms/Utils/GlobalStatus.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/GlobalStatus.cpp b/llvm/lib/Transforms/Utils/GlobalStatus.cpp index 44b7d25d519..3893a752503 100644 --- a/llvm/lib/Transforms/Utils/GlobalStatus.cpp +++ b/llvm/lib/Transforms/Utils/GlobalStatus.cpp @@ -49,6 +49,10 @@ bool llvm::isSafeToDestroyConstant(const Constant *C) { static bool analyzeGlobalAux(const Value *V, GlobalStatus &GS, SmallPtrSetImpl<const PHINode *> &PhiUsers) { + if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(V)) + if (GV->isExternallyInitialized()) + GS.StoredType = GlobalStatus::StoredOnce; + for (const Use &U : V->uses()) { const User *UR = U.getUser(); if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(UR)) { |

