diff options
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/include/llvm/Transforms/Utils/GuardUtils.h | 4 | ||||
| -rw-r--r-- | llvm/lib/Analysis/AliasSetTracker.cpp | 4 | ||||
| -rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 4 | ||||
| -rw-r--r-- | llvm/lib/Transforms/Scalar/EarlyCSE.cpp | 3 | ||||
| -rw-r--r-- | llvm/lib/Transforms/Scalar/GuardWidening.cpp | 7 | ||||
| -rw-r--r-- | llvm/lib/Transforms/Scalar/JumpThreading.cpp | 6 | ||||
| -rw-r--r-- | llvm/lib/Transforms/Scalar/LICM.cpp | 3 | ||||
| -rw-r--r-- | llvm/lib/Transforms/Scalar/LowerGuardIntrinsic.cpp | 6 | ||||
| -rw-r--r-- | llvm/lib/Transforms/Utils/GuardUtils.cpp | 6 | 
9 files changed, 19 insertions, 24 deletions
diff --git a/llvm/include/llvm/Transforms/Utils/GuardUtils.h b/llvm/include/llvm/Transforms/Utils/GuardUtils.h index 4850fc694f8..537045edafe 100644 --- a/llvm/include/llvm/Transforms/Utils/GuardUtils.h +++ b/llvm/include/llvm/Transforms/Utils/GuardUtils.h @@ -17,10 +17,6 @@ namespace llvm {  class CallInst;  class Function; -class User; - -/// Returns true iff \p U has semantics of a guard. -bool isGuard(const User *U);  /// Splits control flow at point of \p Guard, replacing it with explicit branch  /// by the condition of guard's first argument. The taken branch then goes to diff --git a/llvm/lib/Analysis/AliasSetTracker.cpp b/llvm/lib/Analysis/AliasSetTracker.cpp index fd9263fcf19..377db8a569f 100644 --- a/llvm/lib/Analysis/AliasSetTracker.cpp +++ b/llvm/lib/Analysis/AliasSetTracker.cpp @@ -34,7 +34,6 @@  #include "llvm/Support/Debug.h"  #include "llvm/Support/ErrorHandling.h"  #include "llvm/Support/raw_ostream.h" -#include "llvm/Transforms/Utils/GuardUtils.h"  #include <cassert>  #include <cstdint>  #include <vector> @@ -173,7 +172,8 @@ void AliasSet::addUnknownInst(Instruction *I, AliasAnalysis &AA) {    // Guards are marked as modifying memory for control flow modelling purposes,    // but don't actually modify any specific memory location.    using namespace PatternMatch; -  bool MayWriteMemory = I->mayWriteToMemory() && !isGuard(I) && +  bool MayWriteMemory = I->mayWriteToMemory() && +    !match(I, m_Intrinsic<Intrinsic::experimental_guard>()) &&      !(I->use_empty() && match(I, m_Intrinsic<Intrinsic::invariant_start>()));    if (!MayWriteMemory) {      Alias = SetMayAlias; diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 527673f47d8..a207a5064db 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -66,7 +66,6 @@  #include "llvm/Support/ErrorHandling.h"  #include "llvm/Support/KnownBits.h"  #include "llvm/Support/MathExtras.h" -#include "llvm/Transforms/Utils/GuardUtils.h"  #include <algorithm>  #include <array>  #include <cassert> @@ -1903,7 +1902,8 @@ static bool isKnownNonNullFromDominatingCondition(const Value *V,            BasicBlockEdge Edge(BI->getParent(), NonNullSuccessor);            if (Edge.isSingleEdge() && DT->dominates(Edge, CtxI->getParent()))              return true; -        } else if (Pred == ICmpInst::ICMP_NE && isGuard(Curr) && +        } else if (Pred == ICmpInst::ICMP_NE && +                   match(Curr, m_Intrinsic<Intrinsic::experimental_guard>()) &&                     DT->dominates(cast<Instruction>(Curr), CtxI)) {            return true;          } diff --git a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp index d24ad0327f1..533d16e088c 100644 --- a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp +++ b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp @@ -54,7 +54,6 @@  #include "llvm/Support/RecyclingAllocator.h"  #include "llvm/Support/raw_ostream.h"  #include "llvm/Transforms/Scalar.h" -#include "llvm/Transforms/Utils/GuardUtils.h"  #include <cassert>  #include <deque>  #include <memory> @@ -864,7 +863,7 @@ bool EarlyCSE::processNode(DomTreeNode *Node) {        continue;      } -    if (isGuard(Inst)) { +    if (match(Inst, m_Intrinsic<Intrinsic::experimental_guard>())) {        if (auto *CondI =                dyn_cast<Instruction>(cast<CallInst>(Inst)->getArgOperand(0))) {          if (SimpleValue::canHandle(CondI)) { diff --git a/llvm/lib/Transforms/Scalar/GuardWidening.cpp b/llvm/lib/Transforms/Scalar/GuardWidening.cpp index 428c8bf9153..68be46ec07b 100644 --- a/llvm/lib/Transforms/Scalar/GuardWidening.cpp +++ b/llvm/lib/Transforms/Scalar/GuardWidening.cpp @@ -57,7 +57,6 @@  #include "llvm/Support/Debug.h"  #include "llvm/Support/KnownBits.h"  #include "llvm/Transforms/Scalar.h" -#include "llvm/Transforms/Utils/GuardUtils.h"  #include "llvm/Transforms/Utils/LoopUtils.h"  using namespace llvm; @@ -108,6 +107,12 @@ static void setCondition(Instruction *I, Value *NewCond) {    cast<BranchInst>(I)->setCondition(NewCond);  } +// Whether or not the particular instruction \p I is a guard. +static bool isGuard(const Instruction *I) { +  using namespace llvm::PatternMatch; +  return match(I, m_Intrinsic<Intrinsic::experimental_guard>()); +} +  // Eliminates the guard instruction properly.  static void eliminateGuard(Instruction *GuardInst) {    GuardInst->eraseFromParent(); diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp index ddcc3dad93d..39895dc6187 100644 --- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp +++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp @@ -65,7 +65,6 @@  #include "llvm/Transforms/Scalar.h"  #include "llvm/Transforms/Utils/BasicBlockUtils.h"  #include "llvm/Transforms/Utils/Cloning.h" -#include "llvm/Transforms/Utils/GuardUtils.h"  #include "llvm/Transforms/Utils/Local.h"  #include "llvm/Transforms/Utils/SSAUpdater.h"  #include "llvm/Transforms/Utils/ValueMapper.h" @@ -2608,8 +2607,9 @@ bool JumpThreadingPass::ProcessGuards(BasicBlock *BB) {    if (auto *BI = dyn_cast<BranchInst>(Parent->getTerminator()))      for (auto &I : *BB) -      if (isGuard(&I) && ThreadGuard(BB, cast<IntrinsicInst>(&I), BI)) -        return true; +      if (match(&I, m_Intrinsic<Intrinsic::experimental_guard>())) +        if (ThreadGuard(BB, cast<IntrinsicInst>(&I), BI)) +          return true;    return false;  } diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp index 10f59d23eab..94fcdaf3c08 100644 --- a/llvm/lib/Transforms/Scalar/LICM.cpp +++ b/llvm/lib/Transforms/Scalar/LICM.cpp @@ -66,7 +66,6 @@  #include "llvm/Transforms/Scalar.h"  #include "llvm/Transforms/Scalar/LoopPassManager.h"  #include "llvm/Transforms/Utils/BasicBlockUtils.h" -#include "llvm/Transforms/Utils/GuardUtils.h"  #include "llvm/Transforms/Utils/LoopUtils.h"  #include "llvm/Transforms/Utils/SSAUpdater.h"  #include <algorithm> @@ -528,7 +527,7 @@ bool llvm::hoistRegion(DomTreeNode *N, AliasAnalysis *AA, LoopInfo *LI,        using namespace PatternMatch;        if (((I.use_empty() &&              match(&I, m_Intrinsic<Intrinsic::invariant_start>())) || -           isGuard(&I)) && +           match(&I, m_Intrinsic<Intrinsic::experimental_guard>())) &&            IsMustExecute && IsMemoryNotModified &&            CurLoop->hasLoopInvariantOperands(&I)) {          hoist(I, DT, CurLoop, SafetyInfo, ORE); diff --git a/llvm/lib/Transforms/Scalar/LowerGuardIntrinsic.cpp b/llvm/lib/Transforms/Scalar/LowerGuardIntrinsic.cpp index dd81c975e93..fac57014740 100644 --- a/llvm/lib/Transforms/Scalar/LowerGuardIntrinsic.cpp +++ b/llvm/lib/Transforms/Scalar/LowerGuardIntrinsic.cpp @@ -49,8 +49,10 @@ static bool lowerGuardIntrinsic(Function &F) {    SmallVector<CallInst *, 8> ToLower;    for (auto &I : instructions(F)) -    if (isGuard(&I)) -      ToLower.push_back(cast<CallInst>(&I)); +    if (auto *CI = dyn_cast<CallInst>(&I)) +      if (auto *F = CI->getCalledFunction()) +        if (F->getIntrinsicID() == Intrinsic::experimental_guard) +          ToLower.push_back(CI);    if (ToLower.empty())      return false; diff --git a/llvm/lib/Transforms/Utils/GuardUtils.cpp b/llvm/lib/Transforms/Utils/GuardUtils.cpp index 5a9a9df9fa3..08de0a4c53e 100644 --- a/llvm/lib/Transforms/Utils/GuardUtils.cpp +++ b/llvm/lib/Transforms/Utils/GuardUtils.cpp @@ -15,7 +15,6 @@  #include "llvm/IR/Instructions.h"  #include "llvm/IR/IRBuilder.h"  #include "llvm/IR/MDBuilder.h" -#include "llvm/IR/PatternMatch.h"  #include "llvm/Transforms/Utils/BasicBlockUtils.h"  using namespace llvm; @@ -25,11 +24,6 @@ static cl::opt<uint32_t> PredicatePassBranchWeight(      cl::desc("The probability of a guard failing is assumed to be the "               "reciprocal of this value (default = 1 << 20)")); -bool llvm::isGuard(const User *U) { -  using namespace llvm::PatternMatch; -  return match(U, m_Intrinsic<Intrinsic::experimental_guard>()); -} -  void llvm::makeGuardControlFlowExplicit(Function *DeoptIntrinsic,                                          CallInst *Guard) {    OperandBundleDef DeoptOB(*Guard->getOperandBundle(LLVMContext::OB_deopt));  | 

