Skip to content

Commit 0b72b9d

Browse files
committed
[ValueLattice] Simplify canTrackGlobalVariableInterprocedurally (NFC).
using all_of and checking for valid users in the lambda seems more straight forward. Also adds a comment explaining what we are checking.
1 parent fccd29d commit 0b72b9d

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

llvm/lib/Analysis/ValueLatticeUtils.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,14 @@ bool llvm::canTrackGlobalVariableInterprocedurally(GlobalVariable *GV) {
2828
if (GV->isConstant() || !GV->hasLocalLinkage() ||
2929
!GV->hasDefinitiveInitializer())
3030
return false;
31-
return !any_of(GV->users(), [&](User *U) {
32-
if (auto *Store = dyn_cast<StoreInst>(U)) {
33-
if (Store->getValueOperand() == GV || Store->isVolatile())
34-
return true;
35-
} else if (auto *Load = dyn_cast<LoadInst>(U)) {
36-
if (Load->isVolatile())
37-
return true;
38-
} else {
39-
return true;
40-
}
31+
return all_of(GV->users(), [&](User *U) {
32+
// Currently all users of a global variable have to be none-volatile loads
33+
// or stores and the global cannot be stored itself.
34+
if (auto *Store = dyn_cast<StoreInst>(U))
35+
return Store->getValueOperand() != GV && !Store->isVolatile();
36+
if (auto *Load = dyn_cast<LoadInst>(U))
37+
return !Load->isVolatile();
38+
4139
return false;
4240
});
4341
}

0 commit comments

Comments
 (0)