summaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ValueLatticeUtils.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2020-07-26 19:36:28 +0000
committerDimitry Andric <dim@FreeBSD.org>2020-07-26 19:36:28 +0000
commitcfca06d7963fa0909f90483b42a6d7d194d01e08 (patch)
tree209fb2a2d68f8f277793fc8df46c753d31bc853b /llvm/lib/Analysis/ValueLatticeUtils.cpp
parent706b4fc47bbc608932d3b491ae19a3b9cde9497b (diff)
Notes
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;
});
}