forked from OSchip/llvm-project
[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.
This commit is contained in:
parent
fccd29ddde
commit
0b72b9d07f
|
@ -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;
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue