28 return &
F->getValueSymbolTable();
43 :
Value(
Type::getLabelTy(C),
Value::BasicBlockVal), Parent(nullptr) {
48 assert(!InsertBefore &&
49 "Cannot insert block before another block with no function!");
55 assert(NewParent &&
"Expected a parent");
56 assert(!Parent &&
"Already has a parent");
72 assert(!
use_empty() &&
"There should be at least one blockaddress!");
83 assert(
getParent() ==
nullptr &&
"BasicBlock still linked into the program!");
88 void BasicBlock::setParent(
Function *parent) {
90 InstList.setSymTabObject(&Parent, 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())
167 if (!isa<PHINode>(I))
174 if (!isa<PHINode>(I) && !isa<DbgInfoIntrinsic>(I))
181 if (isa<PHINode>(I) || isa<DbgInfoIntrinsic>(I))
184 if (
auto *II = dyn_cast<IntrinsicInst>(&I))
185 if (II->getIntrinsicID() == Intrinsic::lifetime_start ||
186 II->getIntrinsicID() == Intrinsic::lifetime_end)
200 if (isa<LandingPadInst>(InsertPt)) ++InsertPt;
206 I->dropAllReferences();
213 if (PI == E)
return nullptr;
216 return (PI == E) ? ThePred :
nullptr ;
226 if (PI == E)
return nullptr;
229 for (;PI != E; ++PI) {
240 if (SI == E)
return nullptr;
243 return (SI == E) ? TheSucc :
nullptr ;
248 if (SI == E)
return NULL;
251 for (;SI != E; ++
SI) {
267 bool DontDeleteUselessPHIs) {
270 "removePredecessor: BB is not a predecessor!");
272 if (InstList.
empty())
return;
289 assert(max_idx != 0 &&
"PHI Node in block with 0 predecessors!?!?!");
294 if (
this == Other) max_idx = 3;
298 if (max_idx <= 2 && !DontDeleteUselessPHIs) {
302 PN->removeIncomingValue(Pred, !DontDeleteUselessPHIs);
306 if (PN->getIncomingValue(0) != PN)
307 PN->replaceAllUsesWith(PN->getIncomingValue(0));
326 Value* PNV =
nullptr;
349 assert(
getTerminator() &&
"Can't use splitBasicBlock on degenerate BB!");
350 assert(I != InstList.
end() &&
351 "Trying to get me to create degenerate basic block!");
354 .getNodePtrUnchecked();
ReturnInst - Return a value (possibly void), from a function.
iplist< Instruction >::iterator eraseFromParent()
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 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...
CallInst - 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...
BlockAddress - The address of a basic block.
void push_back(NodeTy *val)
Value * removeIncomingValue(unsigned Idx, bool DeletePHIIfEmpty=true)
removeIncomingValue - 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.
NodeTy * getPrevNode()
Get the previous node, or 0 for the list head.
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
getContext - Return the LLVMContext in which this type was uniqued.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
unsigned getNumIncomingValues() const
getNumIncomingValues - Return the number of incoming edges
Interval::succ_iterator succ_end(Interval *I)
unsigned getNumSuccessors() const
Return the number of successors that this terminator has.
void replaceSuccessorsPhiUsesWith(BasicBlock *New)
Update all phi nodes in this basic block's successors to refer to basic block New instead of to it...
LandingPadInst - The landingpad instruction holds all of the information necessary to generate correc...
Subclasses of this class are all able to terminate a basic block.
void setDebugLoc(DebugLoc Loc)
setDebugLoc - Set the debug location information for this instruction.
LLVM Basic Block Representation.
Value * hasConstantValue() const
hasConstantValue - 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...
BasicBlock * getSuccessor(unsigned idx) const
Return the specified successor.
This is an important class for using LLVM in a threaded context.
BranchInst - 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
getIncomingBlock - Return incoming basic block number i.
const InstListType & getInstList() const
Return the underlying instruction list container.
iterator insert(iterator where, NodeTy *New)
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.
static UndefValue * get(Type *T)
get() - 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...
iplist - The subset of list functionality that can safely be used on nodes of polymorphic types...
iterator erase(iterator where)
void removeFromParent()
Unlink 'this' from the containing function, but do not delete it.
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
void setIncomingBlock(unsigned i, BasicBlock *BB)
Type * getType() const
All values are typed, get the type of this value.
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
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)
void splice(iterator where, iplist &L2)
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.
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)
static IntegerType * getInt32Ty(LLVMContext &C)
iplist< 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.
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.
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...
NodeTy * remove(iterator &IT)
int getBasicBlockIndex(const BasicBlock *BB) const
getBasicBlockIndex - Return the first index of the specified basic block in the value list for this P...
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...