71 #define DEBUG_TYPE "code-extractor" 79 cl::desc(
"Aggregate arguments to code-extracted functions"));
84 bool AllowVarArgs,
bool AllowAlloca) {
97 while (!ToVisit.
empty()) {
99 if (!Visited.
insert(Curr).second)
101 if (isa<BlockAddress const>(Curr))
104 if (isa<Instruction>(Curr) && cast<Instruction>(Curr)->
getParent() != &BB)
107 for (
auto const &U : Curr->
operands()) {
108 if (
auto *UU = dyn_cast<User>(U))
116 if (isa<AllocaInst>(
I)) {
122 if (
const auto *II = dyn_cast<InvokeInst>(
I)) {
125 if (
auto *UBB = II->getUnwindDest())
126 if (!Result.
count(UBB))
133 if (
const auto *CSI = dyn_cast<CatchSwitchInst>(
I)) {
134 if (
auto *UBB = CSI->getUnwindDest())
135 if (!Result.
count(UBB))
137 for (
auto *HBB : CSI->handlers())
138 if (!Result.
count(const_cast<BasicBlock*>(HBB)))
145 if (
const auto *CPI = dyn_cast<CatchPadInst>(
I)) {
146 for (
const auto *U : CPI->users())
147 if (
const auto *CRI = dyn_cast<CatchReturnInst>(U))
148 if (!Result.
count(const_cast<BasicBlock*>(CRI->getParent())))
156 if (
const auto *CPI = dyn_cast<CleanupPadInst>(
I)) {
157 for (
const auto *U : CPI->users())
158 if (
const auto *CRI = dyn_cast<CleanupReturnInst>(U))
159 if (!Result.
count(const_cast<BasicBlock*>(CRI->getParent())))
163 if (
const auto *CRI = dyn_cast<CleanupReturnInst>(
I)) {
164 if (
auto *UBB = CRI->getUnwindDest())
165 if (!Result.
count(UBB))
170 if (
const CallInst *CI = dyn_cast<CallInst>(
I))
171 if (
const Function *
F = CI->getCalledFunction())
172 if (
F->getIntrinsicID() == Intrinsic::vastart) {
186 bool AllowVarArgs,
bool AllowAlloca) {
187 assert(!BBs.
empty() &&
"The set of blocks to extract must be non-empty");
197 if (!Result.insert(BB))
201 for (
auto *BB : Result) {
206 if (BB == Result.front()) {
208 LLVM_DEBUG(
dbgs() <<
"The first block cannot be an unwind block\n");
217 if (!Result.count(PBB)) {
219 dbgs() <<
"No blocks in this region may have entries from " 220 "outside the region except for the first block!\n");
233 BPI(BPI), AllowVarArgs(AllowVarArgs),
240 BPI(BPI), AllowVarArgs(
false),
249 if (Blocks.
count(
I->getParent()))
258 if (isa<Argument>(V))
return true;
260 if (!Blocks.
count(
I->getParent()))
267 auto hasNonCommonExitSucc = [&](
BasicBlock *Block) {
270 if (Blocks.
count(Succ))
272 if (!CommonExitBlock) {
273 CommonExitBlock = Succ;
276 if (CommonExitBlock == Succ)
284 if (
any_of(Blocks, hasNonCommonExitSucc))
287 return CommonExitBlock;
295 if (Blocks.count(&BB))
298 if (isa<DbgInfoIntrinsic>(II))
301 unsigned Opcode = II.getOpcode();
302 Value *MemAddr =
nullptr;
314 if (dyn_cast<Constant>(MemAddr))
317 if (!dyn_cast<AllocaInst>(Base) || Base == AI)
330 if (II.mayHaveSideEffects())
342 BasicBlock *SinglePredFromOutlineRegion =
nullptr;
343 assert(!Blocks.count(CommonExitBlock) &&
344 "Expect a block outside the region!");
346 if (!Blocks.count(Pred))
348 if (!SinglePredFromOutlineRegion) {
349 SinglePredFromOutlineRegion = Pred;
350 }
else if (SinglePredFromOutlineRegion != Pred) {
351 SinglePredFromOutlineRegion =
nullptr;
356 if (SinglePredFromOutlineRegion)
357 return SinglePredFromOutlineRegion;
363 while (I != BB->end()) {
376 assert(!getFirstPHI(CommonExitBlock) &&
"Phi not expected");
385 if (Blocks.count(Pred))
390 Blocks.insert(CommonExitBlock);
391 return CommonExitBlock;
400 if (Blocks.count(&BB))
412 auto GetLifeTimeMarkers =
414 bool &HoistLifeEnd) -> std::pair<Instruction *, Instruction *> {
415 Instruction *LifeStart =
nullptr, *LifeEnd =
nullptr;
423 return std::make_pair<Instruction *>(
nullptr,
nullptr);
424 LifeStart = IntrInst;
428 return std::make_pair<Instruction *>(
nullptr,
nullptr);
435 return std::make_pair<Instruction *>(
nullptr,
nullptr);
438 if (!LifeStart || !LifeEnd)
439 return std::make_pair<Instruction *>(
nullptr,
nullptr);
444 if ((SinkLifeStart || HoistLifeEnd) &&
446 return std::make_pair<Instruction *>(
nullptr,
nullptr);
449 if (HoistLifeEnd && !ExitBlock)
450 return std::make_pair<Instruction *>(
nullptr,
nullptr);
452 return std::make_pair(LifeStart, LifeEnd);
455 bool SinkLifeStart =
false, HoistLifeEnd =
false;
456 auto Markers = GetLifeTimeMarkers(AI, SinkLifeStart, HoistLifeEnd);
460 SinkCands.
insert(Markers.first);
463 HoistCands.
insert(Markers.second);
470 if (U->stripInBoundsConstantOffsets() == AI) {
471 SinkLifeStart =
false;
472 HoistLifeEnd =
false;
474 Markers = GetLifeTimeMarkers(Bitcast, SinkLifeStart, HoistLifeEnd);
483 MarkerAddr =
nullptr;
490 SinkCands.
insert(Markers.first);
492 SinkCands.
insert(MarkerAddr);
495 HoistCands.
insert(Markers.second);
526 void CodeExtractor::severSplitPHINodes(
BasicBlock *&Header) {
527 unsigned NumPredsFromRegion = 0;
528 unsigned NumPredsOutsideRegion = 0;
539 ++NumPredsFromRegion;
541 ++NumPredsOutsideRegion;
545 if (NumPredsOutsideRegion <= 1)
return;
557 Blocks.remove(OldPred);
558 Blocks.insert(NewBB);
563 if (NumPredsFromRegion) {
564 PHINode *PN = cast<PHINode>(OldPred->begin());
576 for (AfterPHIs = OldPred->begin(); isa<PHINode>(AfterPHIs); ++AfterPHIs) {
577 PHINode *PN = cast<PHINode>(AfterPHIs);
583 NewPN->addIncoming(PN, OldPred);
598 void CodeExtractor::splitReturnBlocks() {
600 if (
ReturnInst *RI = dyn_cast<ReturnInst>(Block->getTerminator())) {
602 Block->splitBasicBlock(RI->getIterator(), Block->getName() +
".ret");
631 switch (NumExitBlocks) {
638 std::vector<Type *> paramTy;
641 for (
Value *value : inputs) {
643 paramTy.push_back(value->getType());
647 for (
Value *output : outputs) {
650 paramTy.push_back(output->getType());
656 dbgs() <<
"Function type: " << *RetTy <<
" f(";
657 for (
Type *i : paramTy)
658 dbgs() << *i <<
", ";
663 if (AggregateArgs && (inputs.size() + outputs.size() > 0)) {
670 AllowVarArgs && oldFunction->
isVarArg());
683 newFunction->setHasUWTable();
693 if (Attr.isStringAttribute()) {
694 if (Attr.getKindAsString() ==
"thunk")
697 switch (Attr.getKindAsEnum()) {
701 case Attribute::Alignment:
702 case Attribute::AllocSize:
703 case Attribute::ArgMemOnly:
704 case Attribute::Builtin:
705 case Attribute::ByVal:
707 case Attribute::Dereferenceable:
708 case Attribute::DereferenceableOrNull:
709 case Attribute::InAlloca:
710 case Attribute::InReg:
711 case Attribute::InaccessibleMemOnly:
712 case Attribute::InaccessibleMemOrArgMemOnly:
714 case Attribute::Naked:
715 case Attribute::Nest:
717 case Attribute::NoBuiltin:
718 case Attribute::NoCapture:
719 case Attribute::NoReturn:
721 case Attribute::NonNull:
722 case Attribute::ReadNone:
723 case Attribute::ReadOnly:
724 case Attribute::Returned:
725 case Attribute::ReturnsTwice:
726 case Attribute::SExt:
727 case Attribute::Speculatable:
728 case Attribute::StackAlignment:
729 case Attribute::StructRet:
730 case Attribute::SwiftError:
731 case Attribute::SwiftSelf:
732 case Attribute::WriteOnly:
733 case Attribute::ZExt:
737 case Attribute::AlwaysInline:
739 case Attribute::NoRecurse:
740 case Attribute::InlineHint:
741 case Attribute::MinSize:
742 case Attribute::NoDuplicate:
743 case Attribute::NoImplicitFloat:
744 case Attribute::NoInline:
745 case Attribute::NonLazyBind:
746 case Attribute::NoRedZone:
747 case Attribute::NoUnwind:
748 case Attribute::OptForFuzzing:
749 case Attribute::OptimizeNone:
750 case Attribute::OptimizeForSize:
751 case Attribute::SafeStack:
752 case Attribute::ShadowCallStack:
753 case Attribute::SanitizeAddress:
754 case Attribute::SanitizeMemory:
755 case Attribute::SanitizeThread:
756 case Attribute::SanitizeHWAddress:
757 case Attribute::StackProtect:
758 case Attribute::StackProtectReq:
759 case Attribute::StackProtectStrong:
760 case Attribute::StrictFP:
761 case Attribute::UWTable:
762 case Attribute::NoCfCheck:
766 newFunction->addFnAttr(Attr);
768 newFunction->getBasicBlockList().push_back(newRootNode);
775 for (
unsigned i = 0, e = inputs.size(); i != e; ++i) {
783 StructTy, &*AI, Idx,
"gep_" + inputs[i]->
getName(), TI);
788 std::vector<User *>
Users(inputs[i]->user_begin(), inputs[i]->user_end());
791 if (Blocks.count(inst->getParent()))
792 inst->replaceUsesOfWith(inputs[i], RewriteVal);
796 if (!AggregateArgs) {
797 AI = newFunction->arg_begin();
798 for (
unsigned i = 0, e = inputs.size(); i != e; ++i, ++AI)
799 AI->
setName(inputs[i]->getName());
800 for (
unsigned i = 0, e = outputs.size(); i != e; ++i, ++AI)
801 AI->
setName(outputs[i]->getName()+
".out");
808 for (
unsigned i = 0, e =
Users.size(); i != e; ++i)
812 if (!Blocks.count(TI->getParent()) &&
813 TI->getParent()->getParent() == oldFunction)
814 TI->replaceUsesOfWith(header, newHeader);
827 std::vector<Value *> params, StructValues, ReloadOutputs, Reloads;
834 for (
Value *input : inputs)
836 StructValues.push_back(input);
838 params.push_back(input);
841 for (
Value *output : outputs) {
843 StructValues.push_back(output);
847 nullptr, output->getName() +
".loc",
849 ReloadOutputs.push_back(alloca);
850 params.push_back(alloca);
856 if (AggregateArgs && (inputs.size() + outputs.size() > 0)) {
857 std::vector<Type *> ArgTypes;
859 ve = StructValues.end(); v != ve; ++v)
860 ArgTypes.push_back((*v)->getType());
867 params.push_back(Struct);
869 for (
unsigned i = 0, e = inputs.size(); i != e; ++i) {
874 StructArgTy, Struct, Idx,
"gep_" + StructValues[i]->
getName());
883 NumExitBlocks > 1 ?
"targetBlock" :
"");
895 unsigned FirstOut = inputs.size();
897 std::advance(OutputArgBegin, inputs.size());
901 for (
unsigned i = 0, e = outputs.size(); i != e; ++i) {
902 Value *Output =
nullptr;
908 StructArgTy, Struct, Idx,
"gep_reload_" + outputs[i]->
getName());
912 Output = ReloadOutputs[i];
915 Reloads.push_back(load);
917 std::vector<User *>
Users(outputs[i]->user_begin(), outputs[i]->user_end());
918 for (
unsigned u = 0, e = Users.size(); u != e; ++u) {
931 if (isa<PHINode>(InsertPt))
935 "Number of output arguments should match " 936 "the amount of defined values");
942 StructArgTy, &*OAI, Idx,
"gep_" + outputs[i]->
getName(), InsertPt);
943 new StoreInst(outputs[i], GEP, InsertPt);
948 new StoreInst(outputs[i], &*OAI, InsertPt);
956 codeReplacer, 0, codeReplacer);
963 std::map<BasicBlock *, BasicBlock *> ExitBlockMap;
965 unsigned switchVal = 0;
972 BasicBlock *&NewTarget = ExitBlockMap[OldTarget];
977 OldTarget->
getName() +
".exitStub",
979 unsigned SuccNum = switchVal++;
981 Value *brVal =
nullptr;
982 switch (NumExitBlocks) {
1008 switch (NumExitBlocks) {
1051 void CodeExtractor::moveCodeToFunction(
Function *newFunction) {
1065 void CodeExtractor::calculateNewCallTerminatorWeights(
1077 Distribution BranchDist;
1081 BlockNode ExitNode(i);
1082 uint64_t ExitFreq = ExitWeights[TI->
getSuccessor(i)].getFrequency();
1084 BranchDist.addExit(ExitNode, ExitFreq);
1090 if (BranchDist.Total == 0)
1094 BranchDist.normalize();
1097 for (
unsigned I = 0,
E = BranchDist.Weights.
size();
I <
E; ++
I) {
1098 const auto &Weight = BranchDist.Weights[
I];
1101 BranchWeights[Weight.TargetNode.Index] = Weight.Amount;
1123 if (
const CallInst *CI = dyn_cast<CallInst>(&
I))
1124 if (
const Function *
F = CI->getCalledFunction())
1125 return F->getIntrinsicID() == Intrinsic::vastart ||
1126 F->getIntrinsicID() == Intrinsic::vaend;
1130 for (
auto &BB : *oldFunction) {
1131 if (Blocks.count(&BB))
1137 ValueSet inputs, outputs, SinkingCands, HoistingCands;
1144 assert(BPI &&
"Both BPI and BFI are required to preserve profile info");
1146 if (Blocks.count(Pred))
1154 severSplitPHINodes(header);
1158 splitReturnBlocks();
1162 "codeRepl", oldFunction,
1184 newFuncRoot->getInstList().push_back(BranchI);
1186 findAllocas(SinkingCands, HoistingCands, CommonExit);
1193 for (
auto *II : SinkingCands)
1194 cast<Instruction>(II)->moveBefore(*newFuncRoot,
1195 newFuncRoot->getFirstInsertionPt());
1197 if (!HoistingCands.
empty()) {
1200 for (
auto *II : HoistingCands)
1201 cast<Instruction>(II)->moveBefore(TI);
1211 if (!Blocks.count(*
SI)) {
1221 NumExitBlocks = ExitBlocks.
size();
1224 Function *newFunction = constructFunction(inputs, outputs, header,
1226 codeReplacer, oldFunction,
1232 if (Count.hasValue())
1238 emitCallAndSwitchStatement(newFunction, codeReplacer, inputs, outputs);
1240 moveCodeToFunction(newFunction);
1247 if (BFI && NumExitBlocks > 1)
1248 calculateNewCallTerminatorWeights(codeReplacer, ExitWeights, BPI);
1262 std::vector<BasicBlock *> Succs(
succ_begin(codeReplacer),
1264 for (
unsigned i = 0, e = Succs.size(); i != e; ++i)
1267 std::set<BasicBlock*> ProcessedPreds;
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
Return a value (possibly void), from a function.
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
void push_back(const T &Elt)
A parsed version of the target data layout string in and methods for querying it. ...
static IntegerType * getInt1Ty(LLVMContext &C)
This class represents an incoming formal argument to a Function.
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
NodeTy * getNextNode()
Get the next node, or nullptr for the list tail.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Compute iterated dominance frontiers using a linear time algorithm.
BasicBlock * SplitBlock(BasicBlock *Old, Instruction *SplitPt, DominatorTree *DT=nullptr, LoopInfo *LI=nullptr)
Split the specified block at the specified instruction - everything before SplitPt stays in Old and e...
size_type size() const
Determine the number of elements in the SetVector.
A Module instance is used to store all the information related to an LLVM module. ...
BasicBlock * getSuccessor(unsigned idx) const
Return the specified successor.
void addCase(ConstantInt *OnVal, BasicBlock *Dest)
Add an entry to the switch instruction.
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value *> IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
This class represents a function call, abstracting a target machine's calling convention.
Value * getCondition() const
The two locations do not alias at all.
uint64_t getFrequency() const
Returns the frequency as a fixpoint number scaled by the entry frequency.
LLVMContext & getContext() const
All values hold a context through their type.
static CallInst * Create(Value *Func, ArrayRef< Value *> Args, ArrayRef< OperandBundleDef > Bundles=None, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
An instruction for reading from memory.
iv Induction Variable Users
static IntegerType * getInt16Ty(LLVMContext &C)
LLVMContext & getContext() const
Get the context in which this basic block lives.
bool isReachableFromEntry(const Use &U) const
Provide an overload for a Use.
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
iterator begin()
Instruction iterator methods.
static ReturnInst * Create(LLVMContext &C, Value *retVal=nullptr, Instruction *InsertBefore=nullptr)
unsigned getAllocaAddrSpace() const
Value * removeIncomingValue(unsigned Idx, bool DeletePHIIfEmpty=true)
Remove an incoming value.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
void setEntryCount(ProfileCount Count, const DenseSet< GlobalValue::GUID > *Imports=nullptr)
Set the entry count for this function.
Class to represent struct types.
LLVMContext & getContext() const
Get the global data context.
A Use represents the edge between a Value definition and its users.
bool hasUWTable() const
True if the ABI mandates (or the user requested) that this function be in a unwind table...
static StringRef getName(Value *V)
This file contains the simple types necessary to represent the attributes associated with functions a...
No attributes have been set.
void setName(const Twine &Name)
Change the name of the value.
static StructType * get(LLVMContext &Context, ArrayRef< Type *> Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
Interval::succ_iterator succ_begin(Interval *I)
succ_begin/succ_end - define methods so that Intervals may be used just like BasicBlocks can with the...
Class to represent function types.
Type * getType() const
All values are typed, get the type of this value.
bool insert(const value_type &X)
Insert a new element into the SetVector.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
AttributeList getAttributes() const
Return the attribute list for this Function.
An instruction for storing to memory.
bool hasPersonalityFn() const
Check whether this function has a personality function.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
BasicBlock * getSuccessor(unsigned idx) const
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
size_type count(const key_type &key) const
Count the number of elements of a given key in the SetVector.
Interval::succ_iterator succ_end(Interval *I)
void replaceUsesOfWith(Value *From, Value *To)
Replace uses of one Value with another.
bool isVoidTy() const
Return true if this is 'void'.
const BasicBlock & getEntryBlock() const
an instruction for type-safe pointer arithmetic to access elements of arrays and structs ...
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
Type * getReturnType() const
Returns the type of the ret val.
const Instruction * getFirstNonPHI() const
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
Subclasses of this class are all able to terminate a basic block.
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
void setSuccessor(unsigned idx, BasicBlock *B)
Update the specified successor to point at the provided block.
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
DISubprogram * getSubprogram() const
Get the attached subprogram.
void changeImmediateDominator(DomTreeNodeBase< NodeT > *N, DomTreeNodeBase< NodeT > *NewIDom)
changeImmediateDominator - This method is used to update the dominator tree information when a node's...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
const Instruction & front() const
Distribution of unscaled probability weight.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Interval::pred_iterator pred_begin(Interval *I)
pred_begin/pred_end - define methods so that Intervals may be used just like BasicBlocks can with the...
static Type * getVoidTy(LLVMContext &C)
bool any_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly...
static FunctionType * get(Type *Result, ArrayRef< Type *> Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
Interval::pred_iterator pred_end(Interval *I)
Value * getPointerOperand()
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
self_iterator getIterator()
CaseIt removeCase(CaseIt I)
This method removes the specified case and its successor from the switch instruction.
Sentinal value useful for loops.
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
Class to represent profile counts.
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
DomTreeNodeBase< NodeT > * getNode(const NodeT *BB) const
getNode - return the (Post)DominatorTree node for the specified basic block.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
BranchProbability getEdgeProbability(const BasicBlock *Src, unsigned IndexInSuccessors) const
Get an edge's probability, relative to other out-edges of the Src.
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
bool doesNotThrow() const
Determine if the function cannot unwind.
bool hasAddressTaken() const
Returns true if there are any uses of this basic block other than direct branches, switches, etc.
const InstListType & getInstList() const
Return the underlying instruction list container.
typename vector_type::const_iterator iterator
Iterator for intrusive lists based on ilist_node.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the generic address space (address sp...
void setIncomingBlock(unsigned i, BasicBlock *BB)
static SwitchInst * Create(Value *Value, BasicBlock *Default, unsigned NumCases, Instruction *InsertBefore=nullptr)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Module.h This file contains the declarations for the Module class.
void setEdgeProbability(const BasicBlock *Src, unsigned IndexInSuccessors, BranchProbability Prob)
Set the raw edge probability for the given edge.
void setBlockFreq(const BasicBlock *BB, uint64_t Freq)
LLVM_NODISCARD T pop_back_val()
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
static BranchInst * Create(BasicBlock *IfTrue, Instruction *InsertBefore=nullptr)
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructors - NumReservedValues is a hint for the number of incoming edges that this phi node will h...
pred_range predecessors(BasicBlock *BB)
unsigned getNumIncomingValues() const
Return the number of incoming edges.
BlockFrequency getBlockFreq(const BasicBlock *BB) const
getblockFreq - Return block frequency.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
FunctionType * getFunctionType() const
Returns the FunctionType for me.
void push_back(pointer val)
iterator_range< user_iterator > users()
pointer remove(iterator &IT)
Analysis providing branch probability information.
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
static IntegerType * getInt32Ty(LLVMContext &C)
void setCondition(Value *V)
LLVM_NODISCARD bool empty() const
Represents a single loop in the control flow graph.
StringRef getName() const
Return a constant reference to the value's name.
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
const Function * getParent() const
Return the enclosing method, or null if none.
DomTreeNodeBase< NodeT > * addNewBlock(NodeT *BB, NodeT *DomBB)
Add a new node to the dominator tree information.
bool empty() const
Determine if the SetVector is empty or not.
bool verifyFunction(const Function &F, raw_ostream *OS=nullptr)
Check a function for errors, useful for use when debugging a pass.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
const BasicBlockListType & getBasicBlockList() const
Get the underlying elements of the Function...
Rename collisions when linking (static functions).
BasicBlock * splitBasicBlock(iterator I, const Twine &BBName="")
Split the basic block into two basic blocks at the specified instruction.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
user_iterator user_begin()
const BasicBlock & front() const
unsigned getNumSuccessors() const
Return the number of successors that this terminator has.
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
Constant * getPersonalityFn() const
Get the personality function associated with this function.
succ_range successors(BasicBlock *BB)
void setDefaultDest(BasicBlock *DefaultCase)
A vector that has set insertion semantics.
static const Function * getParent(const Value *V)
AttributeSet getFnAttributes() const
The function attributes are returned.
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, const Twine &N="", Module *M=nullptr)
void setPersonalityFn(Constant *Fn)
static BranchProbability getZero()
const TerminatorInst * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
const Value * stripInBoundsConstantOffsets() const
Strip off pointer casts and all-constant inbounds GEPs.
Value * getPointerOperand()
Optional< uint64_t > getProfileCountFromFreq(uint64_t Freq) const
Returns the estimated profile count of Freq.
Representative of a block.
bool empty() const
empty - Check if the array is empty.
A wrapper class for inspecting calls to intrinsic functions.
const BasicBlock * getParent() const
an instruction to allocate memory on the stack