diff options
Diffstat (limited to 'contrib/llvm/lib/Transforms/Scalar/LowerGuardIntrinsic.cpp')
-rw-r--r-- | contrib/llvm/lib/Transforms/Scalar/LowerGuardIntrinsic.cpp | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/contrib/llvm/lib/Transforms/Scalar/LowerGuardIntrinsic.cpp b/contrib/llvm/lib/Transforms/Scalar/LowerGuardIntrinsic.cpp index 5749100..4f41371 100644 --- a/contrib/llvm/lib/Transforms/Scalar/LowerGuardIntrinsic.cpp +++ b/contrib/llvm/lib/Transforms/Scalar/LowerGuardIntrinsic.cpp @@ -13,7 +13,7 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Transforms/Scalar.h" +#include "llvm/Transforms/Scalar/LowerGuardIntrinsic.h" #include "llvm/ADT/SmallVector.h" #include "llvm/IR/BasicBlock.h" #include "llvm/IR/Function.h" @@ -24,6 +24,7 @@ #include "llvm/IR/MDBuilder.h" #include "llvm/IR/Module.h" #include "llvm/Pass.h" +#include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" using namespace llvm; @@ -34,10 +35,11 @@ static cl::opt<uint32_t> PredicatePassBranchWeight( "reciprocal of this value (default = 1 << 20)")); namespace { -struct LowerGuardIntrinsic : public FunctionPass { +struct LowerGuardIntrinsicLegacyPass : public FunctionPass { static char ID; - LowerGuardIntrinsic() : FunctionPass(ID) { - initializeLowerGuardIntrinsicPass(*PassRegistry::getPassRegistry()); + LowerGuardIntrinsicLegacyPass() : FunctionPass(ID) { + initializeLowerGuardIntrinsicLegacyPassPass( + *PassRegistry::getPassRegistry()); } bool runOnFunction(Function &F) override; @@ -83,7 +85,7 @@ static void MakeGuardControlFlowExplicit(Function *DeoptIntrinsic, DeoptBlockTerm->eraseFromParent(); } -bool LowerGuardIntrinsic::runOnFunction(Function &F) { +static bool lowerGuardIntrinsic(Function &F) { // Check if we can cheaply rule out the possibility of not having any work to // do. auto *GuardDecl = F.getParent()->getFunction( @@ -113,11 +115,23 @@ bool LowerGuardIntrinsic::runOnFunction(Function &F) { return true; } -char LowerGuardIntrinsic::ID = 0; -INITIALIZE_PASS(LowerGuardIntrinsic, "lower-guard-intrinsic", +bool LowerGuardIntrinsicLegacyPass::runOnFunction(Function &F) { + return lowerGuardIntrinsic(F); +} + +char LowerGuardIntrinsicLegacyPass::ID = 0; +INITIALIZE_PASS(LowerGuardIntrinsicLegacyPass, "lower-guard-intrinsic", "Lower the guard intrinsic to normal control flow", false, false) Pass *llvm::createLowerGuardIntrinsicPass() { - return new LowerGuardIntrinsic(); + return new LowerGuardIntrinsicLegacyPass(); +} + +PreservedAnalyses LowerGuardIntrinsicPass::run(Function &F, + FunctionAnalysisManager &AM) { + if (lowerGuardIntrinsic(F)) + return PreservedAnalyses::none(); + + return PreservedAnalyses::all(); } |