summaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ValueLatticeUtils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Analysis/ValueLatticeUtils.cpp')
-rw-r--r--llvm/lib/Analysis/ValueLatticeUtils.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/llvm/lib/Analysis/ValueLatticeUtils.cpp b/llvm/lib/Analysis/ValueLatticeUtils.cpp
index 3f9287e26ce7e..53638c351f722 100644
--- a/llvm/lib/Analysis/ValueLatticeUtils.cpp
+++ b/llvm/lib/Analysis/ValueLatticeUtils.cpp
@@ -28,16 +28,14 @@ bool llvm::canTrackGlobalVariableInterprocedurally(GlobalVariable *GV) {
if (GV->isConstant() || !GV->hasLocalLinkage() ||
!GV->hasDefinitiveInitializer())
return false;
- return !any_of(GV->users(), [&](User *U) {
- if (auto *Store = dyn_cast<StoreInst>(U)) {
- if (Store->getValueOperand() == GV || Store->isVolatile())
- return true;
- } else if (auto *Load = dyn_cast<LoadInst>(U)) {
- if (Load->isVolatile())
- return true;
- } else {
- return true;
- }
+ return all_of(GV->users(), [&](User *U) {
+ // Currently all users of a global variable have to be none-volatile loads
+ // or stores and the global cannot be stored itself.
+ if (auto *Store = dyn_cast<StoreInst>(U))
+ return Store->getValueOperand() != GV && !Store->isVolatile();
+ if (auto *Load = dyn_cast<LoadInst>(U))
+ return !Load->isVolatile();
+
return false;
});
}