diff --git a/lib/Analysis/ValueLatticeUtils.cpp b/lib/Analysis/ValueLatticeUtils.cpp index 3f9287e26ce..53638c351f7 100644 --- a/lib/Analysis/ValueLatticeUtils.cpp +++ b/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(U)) { - if (Store->getValueOperand() == GV || Store->isVolatile()) - return true; - } else if (auto *Load = dyn_cast(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(U)) + return Store->getValueOperand() != GV && !Store->isVolatile(); + if (auto *Load = dyn_cast(U)) + return !Load->isVolatile(); + return false; }); }