• Home
  • Raw
  • Download

Lines Matching +full:ci +full:- +full:pass

1 //===- LowerGuardIntrinsic.cpp - Lower the guard intrinsic ---------------===//
8 //===----------------------------------------------------------------------===//
10 // This pass lowers the llvm.experimental.guard intrinsic to a conditional call
14 //===----------------------------------------------------------------------===//
26 #include "llvm/Pass.h"
32 "guards-predicate-pass-branch-weight", cl::Hidden, cl::init(1 << 20),
48 CallInst *CI) { in MakeGuardControlFlowExplicit() argument
49 OperandBundleDef DeoptOB(*CI->getOperandBundle(LLVMContext::OB_deopt)); in MakeGuardControlFlowExplicit()
50 SmallVector<Value *, 4> Args(std::next(CI->arg_begin()), CI->arg_end()); in MakeGuardControlFlowExplicit()
52 auto *CheckBB = CI->getParent(); in MakeGuardControlFlowExplicit()
54 SplitBlockAndInsertIfThen(CI->getArgOperand(0), CI, true); in MakeGuardControlFlowExplicit()
56 auto *CheckBI = cast<BranchInst>(CheckBB->getTerminator()); in MakeGuardControlFlowExplicit()
60 CheckBI->swapSuccessors(); in MakeGuardControlFlowExplicit()
62 CheckBI->getSuccessor(0)->setName("guarded"); in MakeGuardControlFlowExplicit()
63 CheckBI->getSuccessor(1)->setName("deopt"); in MakeGuardControlFlowExplicit()
65 if (auto *MD = CI->getMetadata(LLVMContext::MD_make_implicit)) in MakeGuardControlFlowExplicit()
66 CheckBI->setMetadata(LLVMContext::MD_make_implicit, MD); in MakeGuardControlFlowExplicit()
68 MDBuilder MDB(CI->getContext()); in MakeGuardControlFlowExplicit()
69 CheckBI->setMetadata(LLVMContext::MD_prof, in MakeGuardControlFlowExplicit()
75 if (DeoptIntrinsic->getReturnType()->isVoidTy()) { in MakeGuardControlFlowExplicit()
78 DeoptCall->setName("deoptcall"); in MakeGuardControlFlowExplicit()
82 DeoptCall->setCallingConv(CI->getCallingConv()); in MakeGuardControlFlowExplicit()
83 DeoptBlockTerm->eraseFromParent(); in MakeGuardControlFlowExplicit()
89 auto *GuardDecl = F.getParent()->getFunction( in runOnFunction()
91 if (!GuardDecl || GuardDecl->use_empty()) in runOnFunction()
96 if (auto *CI = dyn_cast<CallInst>(&I)) in runOnFunction() local
97 if (auto *F = CI->getCalledFunction()) in runOnFunction()
98 if (F->getIntrinsicID() == Intrinsic::experimental_guard) in runOnFunction()
99 ToLower.push_back(CI); in runOnFunction()
106 DeoptIntrinsic->setCallingConv(GuardDecl->getCallingConv()); in runOnFunction()
108 for (auto *CI : ToLower) { in runOnFunction() local
109 MakeGuardControlFlowExplicit(DeoptIntrinsic, CI); in runOnFunction()
110 CI->eraseFromParent(); in runOnFunction()
117 INITIALIZE_PASS(LowerGuardIntrinsic, "lower-guard-intrinsic",
121 Pass *llvm::createLowerGuardIntrinsicPass() { in createLowerGuardIntrinsicPass()