32 #define DEBUG_TYPE "lower-expect-intrinsic"
35 "Number of 'expect' intrinsic instructions handled");
39 cl::desc(
"Weight of the branch likely to be taken (default = 64)"));
42 cl::desc(
"Weight of the branch unlikely to be taken (default = 4)"));
115 if (ExpectedValue->
isOne())
130 bool Changed =
false;
134 if (
BranchInst *BI = dyn_cast<BranchInst>(BB.getTerminator())) {
136 ExpectIntrinsicsHandled++;
137 }
else if (
SwitchInst *
SI = dyn_cast<SwitchInst>(BB.getTerminator())) {
139 ExpectIntrinsicsHandled++;
188 "Lower 'expect' Intrinsics",
false,
false)
191 return new LowerExpectIntrinsic();
iplist< Instruction >::iterator eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing basic block and deletes it...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
STATISTIC(NumFunctions,"Total number of functions")
INITIALIZE_PASS(LowerExpectIntrinsic,"lower-expect","Lower 'expect' Intrinsics", false, false) FunctionPass *llvm
CallInst - This class represents a function call, abstracting a target machine's calling convention...
bool isUnconditional() const
static bool lowerExpectIntrinsic(Function &F)
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
PreservedAnalyses run(Function &F)
Run the pass over the function.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
initializer< Ty > init(const Ty &Val)
An abstract set of preserved analyses following a transformation pass run.
static cl::opt< uint32_t > UnlikelyBranchWeight("unlikely-branch-weight", cl::Hidden, cl::init(4), cl::desc("Weight of the branch unlikely to be taken (default = 4)"))
unsigned getCaseIndex() const
Returns number of current case.
void initializeLowerExpectIntrinsicPass(PassRegistry &)
LLVM Basic Block Representation.
BranchInst - Conditional or Unconditional Branch instruction.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
This instruction compares its operands according to the predicate given to the constructor.
FunctionPass class - This class is used to implement most global optimizations.
Value * getOperand(unsigned i) const
Predicate getPredicate() const
Return the predicate for this instruction.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
LLVMContext & getContext() const
All values hold a context through their type.
void setMetadata(unsigned KindID, MDNode *Node)
setMetadata - Set the metadata of the specified kind to the specified node.
This is the shared class of boolean and integer constants.
Function * getCalledFunction() const
getCalledFunction - Return the function called, or null if this is an indirect function invocation...
CaseIt findCaseValue(const ConstantInt *C)
findCaseValue - Search all of the case values for the specified constant.
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
void setOperand(unsigned i, Value *Val)
Value * getArgOperand(unsigned i) const
getArgOperand/setArgOperand - Return/set the i-th call argument.
static bool handleBranchExpect(BranchInst &BI)
LLVM_ATTRIBUTE_UNUSED_RESULT std::enable_if< !is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Value * getCondition() const
Value * getCondition() const
void setCondition(Value *V)
The header file for the LowerExpectIntrinsic pass as used by the new pass manager.
CaseIt case_default()
Returns an iterator that points to the default case.
unsigned getNumCases() const
getNumCases - return the number of 'cases' in this switch instruction, except the default case ...
void setCondition(Value *V)
SwitchInst - Multiway switch.
static cl::opt< uint32_t > LikelyBranchWeight("likely-branch-weight", cl::Hidden, cl::init(64), cl::desc("Weight of the branch likely to be taken (default = 64)"))
LLVM Value Representation.
static bool handleSwitchExpect(SwitchInst &SI)
bool isOne() const
This is just a convenience method to make client code smaller for a common case.
FunctionPass * createLowerExpectIntrinsicPass()