27 cl::desc(
"The probability of a guard failing is assumed to be the " 28 "reciprocal of this value (default = 1 << 20)"));
36 auto *DeoptBlockTerm =
39 auto *CheckBI = cast<BranchInst>(CheckBB->getTerminator());
43 CheckBI->swapSuccessors();
46 CheckBI->getSuccessor(1)->setName(
"deopt");
48 if (
auto *MD = Guard->
getMetadata(LLVMContext::MD_make_implicit))
49 CheckBI->setMetadata(LLVMContext::MD_make_implicit, MD);
52 CheckBI->setMetadata(LLVMContext::MD_prof,
56 auto *DeoptCall = B.
CreateCall(DeoptIntrinsic,
Args, {DeoptOB},
"");
61 DeoptCall->
setName(
"deoptcall");
73 auto *WC = B.
CreateIntrinsic(Intrinsic::experimental_widenable_condition,
74 {}, {},
nullptr,
"widenable_cond");
75 CheckBI->setCondition(B.
CreateAnd(CheckBI->getCondition(), WC,
76 "exiplicit_guard_cond"));
bool isWidenableBranch(const User *U)
Returns true iff U is a widenable branch (that is, parseWidenableBranch returns true).
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
This class represents lattice values for constants.
BasicBlock * getSuccessor(unsigned Idx) const
Return the specified successor. This instruction must be a terminator.
This class represents a function call, abstracting a target machine's calling convention.
LLVMContext & getContext() const
All values hold a context through their type.
void setWidenableBranchCond(BranchInst *WidenableBR, Value *Cond)
Given a branch we know is widenable (defined per Analysis/GuardUtils.h), set it's condition such that...
User::op_iterator arg_end()
Return the iterator pointing to the end of the argument list.
Value * getCondition() const
Value * getArgOperand(unsigned i) const
A Use represents the edge between a Value definition and its users.
ReturnInst * CreateRet(Value *V)
Create a 'ret <val>' instruction.
void setName(const Twine &Name)
Change the name of the value.
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
Optional< OperandBundleUse > getOperandBundle(StringRef Name) const
Return an operand bundle by name, if present.
bool isVoidTy() const
Return true if this is 'void'.
initializer< Ty > init(const Ty &Val)
Type * getReturnType() const
Returns the type of the ret val.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
LLVM Basic Block Representation.
Conditional or Unconditional Branch instruction.
bool parseWidenableBranch(const User *U, Value *&Condition, Value *&WidenableCondition, BasicBlock *&IfTrueBB, BasicBlock *&IfFalseBB)
If U is widenable branch looking like: cond = ...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
CallInst * CreateIntrinsic(Intrinsic::ID ID, ArrayRef< Type *> Types, ArrayRef< Value *> Args, Instruction *FMFSource=nullptr, const Twine &Name="")
Create a call to intrinsic ID with args, mangled using Types.
void widenWidenableBranch(BranchInst *WidenableBR, Value *NewCond)
Given a branch we know is widenable (defined per Analysis/GuardUtils.h), widen it such that condition...
User::op_iterator arg_begin()
Return the iterator pointing to the beginning of the argument list.
ReturnInst * CreateRetVoid()
Create a 'ret void' instruction.
CallingConv::ID getCallingConv() const
void makeGuardControlFlowExplicit(Function *DeoptIntrinsic, CallInst *Guard, bool UseWC)
Splits control flow at point of Guard, replacing it with explicit branch by the condition of guard's ...
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value *> Args=None, const Twine &Name="", MDNode *FPMathTag=nullptr)
Value * CreateAnd(Value *LHS, Value *RHS, const Twine &Name="")
void setCondition(Value *V)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
void moveBefore(Instruction *MovePos)
Unlink this instruction from its current basic block and insert it into the basic block that MovePos ...
A container for an operand bundle being viewed as a set of values rather than a set of uses...
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Instruction * SplitBlockAndInsertIfThen(Value *Cond, Instruction *SplitBefore, bool Unreachable, MDNode *BranchWeights=nullptr, DominatorTree *DT=nullptr, LoopInfo *LI=nullptr, BasicBlock *ThenBlock=nullptr)
Split the containing block at the specified instruction - everything before SplitBefore stays in the ...
const BasicBlock * getParent() const