From aebe1a106b326e50deae682dcf24c68ba52b30e0 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Thu, 9 Jul 2020 18:31:23 +0100 Subject: [PATCH] [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. --- lib/Analysis/ValueLatticeUtils.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) 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; }); }