Lines Matching +full:ci +full:- +full:pass
1 //===- LowerExpectIntrinsic.cpp - Lower expect intrinsic ------------------===//
8 //===----------------------------------------------------------------------===//
10 // This pass lowers the 'expect' intrinsic to LLVM metadata.
12 //===----------------------------------------------------------------------===//
25 #include "llvm/Pass.h"
32 #define DEBUG_TYPE "lower-expect-intrinsic"
50 "likely-branch-weight", cl::Hidden, cl::init(2000),
53 "unlikely-branch-weight", cl::Hidden, cl::init(1),
57 CallInst *CI = dyn_cast<CallInst>(SI.getCondition()); in handleSwitchExpect() local
58 if (!CI) in handleSwitchExpect()
61 Function *Fn = CI->getCalledFunction(); in handleSwitchExpect()
62 if (!Fn || Fn->getIntrinsicID() != Intrinsic::expect) in handleSwitchExpect()
65 Value *ArgValue = CI->getArgOperand(0); in handleSwitchExpect()
66 ConstantInt *ExpectedValue = dyn_cast<ConstantInt>(CI->getArgOperand(1)); in handleSwitchExpect()
80 MDBuilder(CI->getContext()).createBranchWeights(Weights)); in handleSwitchExpect()
90 // Handle non-optimized IR code like: in handleBranchExpect()
99 CallInst *CI; in handleBranchExpect() local
103 CI = dyn_cast<CallInst>(BI.getCondition()); in handleBranchExpect()
105 if (CmpI->getPredicate() != CmpInst::ICMP_NE) in handleBranchExpect()
107 CI = dyn_cast<CallInst>(CmpI->getOperand(0)); in handleBranchExpect()
110 if (!CI) in handleBranchExpect()
113 Function *Fn = CI->getCalledFunction(); in handleBranchExpect()
114 if (!Fn || Fn->getIntrinsicID() != Intrinsic::expect) in handleBranchExpect()
117 Value *ArgValue = CI->getArgOperand(0); in handleBranchExpect()
118 ConstantInt *ExpectedValue = dyn_cast<ConstantInt>(CI->getArgOperand(1)); in handleBranchExpect()
122 MDBuilder MDB(CI->getContext()); in handleBranchExpect()
127 if (ExpectedValue->isOne()) in handleBranchExpect()
135 CmpI->setOperand(0, ArgValue); in handleBranchExpect()
156 CallInst *CI = dyn_cast<CallInst>(BI++); in lowerExpectIntrinsic() local
157 if (!CI) in lowerExpectIntrinsic()
160 Function *Fn = CI->getCalledFunction(); in lowerExpectIntrinsic()
161 if (Fn && Fn->getIntrinsicID() == Intrinsic::expect) { in lowerExpectIntrinsic()
162 Value *Exp = CI->getArgOperand(0); in lowerExpectIntrinsic()
163 CI->replaceAllUsesWith(Exp); in lowerExpectIntrinsic()
164 CI->eraseFromParent(); in lowerExpectIntrinsic()
182 /// \brief Legacy pass for lowering expect intrinsics out of the IR.
184 /// When this pass is run over a function it uses expect intrinsics which feed
200 INITIALIZE_PASS(LowerExpectIntrinsic, "lower-expect",