1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 04:02:41 +01:00

[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:
Florian Hahn 2020-07-09 18:31:23 +01:00
parent b59dcd9fec
commit aebe1a106b

View File

@ -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;
});
}