diff options
author | Max Kazantsev <max.kazantsev@azul.com> | 2018-08-29 11:37:34 +0000 |
---|---|---|
committer | Max Kazantsev <max.kazantsev@azul.com> | 2018-08-29 11:37:34 +0000 |
commit | 1dafaa87d9c3b25f53bd18cab18725dd1d76023e (patch) | |
tree | 1915f21f63fb0a4f3a8b9b76335a62324dead908 /llvm/lib/Transforms/Utils/GuardUtils.cpp | |
parent | f8f00e5065f728be233a7c644245c2611a008968 (diff) | |
download | llvm-1dafaa87d9c3b25f53bd18cab18725dd1d76023e.zip llvm-1dafaa87d9c3b25f53bd18cab18725dd1d76023e.tar.gz llvm-1dafaa87d9c3b25f53bd18cab18725dd1d76023e.tar.bz2 |
[NFC] Unify guards detection
We have multiple places in code where we try to identify whether or not
some instruction is a guard. This patch factors out this logic into a separate
utility function which works uniformly in all places.
Differential Revision: https://reviews.llvm.org/D51152
Reviewed By: fedor.sergeev
llvm-svn: 340921
Diffstat (limited to 'llvm/lib/Transforms/Utils/GuardUtils.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/GuardUtils.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/GuardUtils.cpp b/llvm/lib/Transforms/Utils/GuardUtils.cpp index 08de0a4..5a9a9df 100644 --- a/llvm/lib/Transforms/Utils/GuardUtils.cpp +++ b/llvm/lib/Transforms/Utils/GuardUtils.cpp @@ -15,6 +15,7 @@ #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; @@ -24,6 +25,11 @@ 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)); |