29 return F->getValueSymbolTable();
43 :
Value(
Type::getLabelTy(C),
Value::BasicBlockVal), Parent(nullptr) {
49 "Cannot insert block before another block with no function!");
55 assert(NewParent &&
"Expected a parent");
56 assert(!Parent &&
"Already has a parent");
83 assert(
getParent() ==
nullptr &&
"BasicBlock still linked into the program!");
88 void BasicBlock::setParent(
Function *parent) {
125 if (InstList.empty())
return nullptr;
130 if (InstList.empty())
return nullptr;
135 if (InstList.empty())
138 if (!RI || RI == &InstList.front())
150 if (
auto *BI = dyn_cast<BitCastInst>(Prev)) {
153 if (!Prev || RV != Prev)
158 if (
auto *CI = dyn_cast<CallInst>(Prev)) {
159 if (CI->isMustTailCall())
166 if (InstList.empty())
169 if (!RI || RI == &InstList.front())
172 if (
auto *CI = dyn_cast_or_null<CallInst>(RI->getPrevNode()))
173 if (
Function *
F = CI->getCalledFunction())
174 if (
F->getIntrinsicID() == Intrinsic::experimental_deoptimize)
182 if (!isa<PHINode>(I))
189 if (!isa<PHINode>(I) && !isa<DbgInfoIntrinsic>(I))
196 if (isa<PHINode>(I) || isa<DbgInfoIntrinsic>(I))
199 if (
auto *II = dyn_cast<IntrinsicInst>(&I))
200 if (II->getIntrinsicID() == Intrinsic::lifetime_start ||
201 II->getIntrinsicID() == Intrinsic::lifetime_end)
215 if (InsertPt->isEHPad()) ++InsertPt;
228 if (PI ==
E)
return nullptr;
231 return (PI ==
E) ? ThePred :
nullptr ;
241 if (PI ==
E)
return nullptr;
244 for (;PI !=
E; ++PI) {
255 if (SI ==
E)
return nullptr;
258 return (SI ==
E) ? TheSucc :
nullptr ;
263 if (SI ==
E)
return nullptr;
266 for (;SI !=
E; ++SI) {
282 bool DontDeleteUselessPHIs) {
285 "removePredecessor: BB is not a predecessor!");
287 if (InstList.empty())
return;
304 assert(max_idx != 0 &&
"PHI Node in block with 0 predecessors!?!?!");
309 if (
this == Other) max_idx = 3;
313 if (max_idx <= 2 && !DontDeleteUselessPHIs) {
317 PN->removeIncomingValue(Pred, !DontDeleteUselessPHIs);
321 if (PN->getIncomingValue(0) != PN)
322 PN->replaceAllUsesWith(PN->getIncomingValue(0));
341 Value* PNV =
nullptr;
353 if (isa<LandingPadInst>(FirstNonPHI))
376 assert(I != InstList.end() &&
377 "Trying to get me to create degenerate basic block!");
423 for (
iterator II = Succ->begin(),
IE = Succ->end(); II !=
IE; ++II) {
Return a value (possibly void), from a function.
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
BasicBlock * getUniqueSuccessor()
Return the successor of this block if it has a unique successor.
This class provides a symbol table of name/value pairs.
BasicBlock * getUniquePredecessor()
Return the predecessor of this block if it has a unique predecessor block.
void removePredecessor(BasicBlock *Pred, bool DontDeleteUselessPHIs=false)
Notify the BasicBlock that the predecessor Pred is no longer able to reach it.
void dropAllReferences()
Drop all references to operands.
BasicBlock * getNextNode()
Get the next node, or nullptr for the list tail.
iterator erase(iterator where)
void insertInto(Function *Parent, BasicBlock *InsertBefore=nullptr)
Insert unlinked basic block into a function.
A Module instance is used to store all the information related to an LLVM module. ...
CallInst * getTerminatingMustTailCall()
Returns the call instruction marked 'musttail' prior to the terminating return instruction of this ba...
This class represents a function call, abstracting a target machine's calling convention.
static Constant * getIntToPtr(Constant *C, Type *Ty, bool OnlyIfReduced=false)
const Function * getParent() const
Return the enclosing method, or null if none.
const Instruction & front() const
iterator begin()
Instruction iterator methods.
Instruction * getFirstNonPHIOrDbg()
Returns a pointer to the first instruction in this block that is not a PHINode or a debug intrinsic...
The address of a basic block.
Value * removeIncomingValue(unsigned Idx, bool DeletePHIIfEmpty=true)
Remove an incoming value.
Value * getReturnValue() const
Convenience accessor. Returns null if there is no return value.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
const Module * getModule() const
Return the module owning the function this basic block belongs to, or nullptr it the function does no...
Instruction * getFirstNonPHI()
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
bool hasAddressTaken() const
Returns true if there are any uses of this basic block other than direct branches, switches, etc.
void setName(const Twine &Name)
Change the name of the value.
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...
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
bool canSplitPredecessors() const
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
unsigned getNumIncomingValues() const
Return the number of incoming edges.
Interval::succ_iterator succ_end(Interval *I)
void replaceSuccessorsPhiUsesWith(BasicBlock *New)
Update all phi nodes in this basic block's successors to refer to basic block New instead of to it...
The landingpad instruction holds all of the information necessary to generate correct exception handl...
Subclasses of this class are all able to terminate a basic block.
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
LLVM Basic Block Representation.
Value * hasConstantValue() const
If the specified PHI node always merges together the same value, return the value, otherwise return null.
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.
Conditional or Unconditional Branch instruction.
This is an important base class in LLVM.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
LandingPadInst * getLandingPadInst()
Return the landingpad instruction associated with the landing pad.
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...
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
void setSymTabObject(TPtr *, TPtr)
setSymTabObject - This is called when (f.e.) the parent of a basic block changes. ...
void splice(iterator where, iplist_impl &L2)
const InstListType & getInstList() const
Return the underlying instruction list container.
Value * getOperand(unsigned i) const
Interval::pred_iterator pred_end(Interval *I)
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
self_iterator getIterator()
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
Instruction * getFirstNonPHIOrDbgOrLifetime()
Returns a pointer to the first instruction in this block that is not a PHINode, a debug intrinsic...
CallInst * getTerminatingDeoptimizeCall()
Returns the call instruction calling .experimental.deoptimize prior to the terminating return instruc...
void removeFromParent()
Unlink 'this' from the containing function, but do not delete it.
Iterator for intrusive lists based on ilist_node.
void moveAfter(BasicBlock *MovePos)
Unlink this basic block from its current function and insert it right after MovePos in the function M...
const BasicBlockListType & getBasicBlockList() const
auto find(R &&Range, const T &Val) -> decltype(std::begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
void setIncomingBlock(unsigned i, BasicBlock *BB)
Type * getType() const
All values are typed, get the type of this value.
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 GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
void push_back(pointer val)
BasicBlock * getSingleSuccessor()
Return the successor of this block if it has a single successor.
BasicBlock * getSinglePredecessor()
Return the predecessor of this block if it has a single predecessor block.
bool isEHPad() const
Return true if the instruction is a variety of EH-block.
pointer remove(iterator &IT)
iterator insert(iterator where, pointer New)
static IntegerType * getInt32Ty(LLVMContext &C)
SymbolTableList< BasicBlock >::iterator eraseFromParent()
Unlink 'this' from the containing function and delete it.
ValueSymbolTable * getValueSymbolTable()
Returns a pointer to the symbol table if one exists.
TerminatorInst * getTerminator()
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
bool isLandingPad() const
Return true if this basic block is a landing pad.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
void destroyConstant()
Called if some element of this constant is no longer valid.
BasicBlock * splitBasicBlock(iterator I, const Twine &BBName="")
Split the basic block into two basic blocks at the specified instruction.
bool hasNUsesOrMore(unsigned N) const
Return true if this value has N users or more.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVMContext & getContext() const
Get the context in which this basic block lives.
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
iterator getFirstInsertionPt()
Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI i...
int getBasicBlockIndex(const BasicBlock *BB) const
Return the first index of the specified basic block in the value list for this PHI.
void moveBefore(BasicBlock *MovePos)
Unlink this basic block from its current function and insert it into the function that MovePos lives ...
void dropAllReferences()
Cause all subinstructions to "let go" of all the references that said subinstructions are maintaining...