Go to the documentation of this file.
13 #ifndef LLVM_IR_BASICBLOCK_H
14 #define LLVM_IR_BASICBLOCK_H
31 class AssemblyAnnotationWriter;
38 class ValueSymbolTable;
106 Function *Parent = nullptr,
107 BasicBlock *InsertBefore = nullptr) {
121 return const_cast<Module *
>(
128 if (InstList.empty() || !InstList.back().isTerminator())
130 return &InstList.back();
308 bool ShouldPreserveUseListOrder =
false,
309 bool IsForDebug =
false)
const;
324 inline size_t size()
const {
return InstList.size(); }
325 inline bool empty()
const {
return InstList.empty(); }
332 template <
typename PHINodeT = PHINode,
typename BBIteratorT = iterator>
335 std::forward_iterator_tag, PHINodeT> {
348 template <
typename PHINodeU,
typename BBIteratorU,
349 typename = std::enable_if_t<
350 std::is_convertible<PHINodeU *, PHINodeT *>::value>>
358 using phi_iterator_impl::iterator_facade_base::operator++;
360 assert(PN &&
"Cannot increment the end iterator!");
361 PN = dyn_cast<PHINodeT>(std::next(BBIteratorT(PN)));
382 const InstListType &getInstList()
const {
return InstList; }
387 static InstListType BasicBlock::*getSublistAccess(Instruction *) {
388 return &BasicBlock::InstList;
397 return V->
getValueID() == Value::BasicBlockVal;
439 bool Before =
false);
441 bool Before =
false) {
476 auto FromItNext = std::next(FromIt);
478 if (ToIt == FromIt || ToIt == FromItNext)
480 splice(ToIt, FromBB, FromIt, FromItNext);
496 return getBasicBlockBits().BlockAddressRefCount != 0;
538 return getBasicBlockBits().InstrOrderValid;
544 BasicBlockBits
Bits = getBasicBlockBits();
545 Bits.InstrOrderValid =
false;
546 setBasicBlockBits(
Bits);
563 #if defined(_AIX) && (!defined(__GNUC__) || defined(__clang__))
566 #define BEGIN_TWO_BYTE_PACK() _Pragma("pack(2)")
567 #define END_TWO_BYTE_PACK() _Pragma("pack(pop)")
569 #define BEGIN_TWO_BYTE_PACK()
570 #define END_TWO_BYTE_PACK()
575 struct BasicBlockBits {
576 unsigned short BlockAddressRefCount : 15;
577 unsigned short InstrOrderValid : 1;
581 #undef BEGIN_TWO_BYTE_PACK
582 #undef END_TWO_BYTE_PACK
585 BasicBlockBits getBasicBlockBits()
const {
586 static_assert(
sizeof(BasicBlockBits) ==
sizeof(
unsigned short),
587 "too many bits for Value::SubclassData");
589 BasicBlockBits AsBits;
590 memcpy(&AsBits, &ValueData,
sizeof(AsBits));
595 void setBasicBlockBits(BasicBlockBits AsBits) {
606 void AdjustBlockAddressRefCount(
int Amt) {
607 BasicBlockBits
Bits = getBasicBlockBits();
608 Bits.BlockAddressRefCount += Amt;
609 setBasicBlockBits(
Bits);
610 assert(
Bits.BlockAddressRefCount < 255 &&
"Refcount wrap-around");
615 void setValueSubclassData(
unsigned short D) {
635 #endif // LLVM_IR_BASICBLOCK_H
const CallInst * getTerminatingDeoptimizeCall() const
Returns the call instruction calling @llvm.experimental.deoptimize prior to the terminating return in...
void splice(BasicBlock::iterator ToIt, BasicBlock *FromBB)
Transfer all instructions from FromBB to this basic block at ToIt.
void print(raw_ostream &OS, AssemblyAnnotationWriter *AAW=nullptr, bool ShouldPreserveUseListOrder=false, bool IsForDebug=false) const
Print the basic block to an output stream with an optional AssemblyAnnotationWriter.
This is an optimization pass for GlobalISel generic memory operations.
const_iterator begin() const
SymbolTableList< Instruction > InstListType
BasicBlock * getSingleSuccessor()
InstListType::iterator iterator
Instruction iterators...
const Function * getParent() const
Return the enclosing method, or null if none.
Instruction * getFirstNonPHIOrDbgOrLifetime(bool SkipPseudoOp=true)
unsigned short getSubclassDataFromValue() const
bool hasNPredecessorsOrMore(unsigned N) const
Return true if this block has N predecessors or more.
iterator_range< filter_iterator< BasicBlock::const_iterator, std::function< bool(const Instruction &)> > > instructionsWithoutDebug(bool SkipPseudoOp=true) const
Return a const iterator range over the instructions in the block, skipping any debug instructions.
The landingpad instruction holds all of the information necessary to generate correct exception handl...
Instruction * getFirstNonPHIOrDbg(bool SkipPseudoOp=true)
An ilist node that can access its parent list.
SymbolTableList< Instruction >::iterator insertInto(BasicBlock *ParentBB, SymbolTableList< Instruction >::iterator It)
Inserts an unlinked instruction into ParentBB at position It and returns the iterator of the inserted...
void replaceSuccessorsPhiUsesWith(BasicBlock *Old, BasicBlock *New)
Update all phi nodes in this basic block's successors to refer to basic block New instead of basic bl...
filter_iterator< BasicBlock::const_iterator, std::function< bool(const Instruction &)> >::difference_type sizeWithoutDebug() const
Return the size of the basic block ignoring debug instructions.
iterator getFirstNonPHIOrDbgOrAlloca()
Specialization of filter_iterator_base for forward iteration only.
SymbolTableList< BasicBlock >::iterator eraseFromParent()
Unlink 'this' from the containing function and delete it.
const BasicBlock * getSingleSuccessor() const
Return the successor of this block if it has a single successor.
BasicBlock * splitBasicBlock(iterator I, const Twine &BBName="", bool Before=false)
Split the basic block into two basic blocks at the specified instruction.
const BasicBlock * getSinglePredecessor() const
Return the predecessor of this block if it has a single predecessor block.
bool hasNPredecessors(unsigned N) const
Return true if this block has exactly N predecessors.
void setValueSubclassData(unsigned short D)
bool canSplitPredecessors() const
BasicBlock * splitBasicBlockBefore(iterator I, const Twine &BBName="")
Split the basic block into two basic blocks at the specified instruction and insert the new basic blo...
CallInst * getPostdominatingDeoptimizeCall()
BasicBlock * getUniqueSuccessor()
const BasicBlock * getUniqueSuccessor() const
Return the successor of this block if it has a unique successor.
LLVM Basic Block Representation.
#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)
void invalidateOrders()
Mark instruction ordering invalid. Done on every instruction insert.
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
(vector float) vec_cmpeq(*A, *B) C
iterator begin()
Instruction iterator methods.
bool isLandingPad() const
Return true if this basic block is a landing pad.
struct LLVMOpaqueBasicBlock * LLVMBasicBlockRef
Represents a basic block of instructions in LLVM IR.
const_iterator getFirstInsertionPt() const
Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI i...
unsigned getValueID() const
Return an ID for the concrete type of this object.
#define END_TWO_BYTE_PACK()
BasicBlock::iterator skipDebugIntrinsics(BasicBlock::iterator It)
Advance It while it points to a debug instruction and return the result.
ValueSymbolTable * getValueSymbolTable()
Returns a pointer to the symbol table if one exists.
PHINodeT & operator*() const
iterator_range< const_phi_iterator > phis() const
Returns a range that iterates over the phis in the basic block.
This class implements an extremely fast bulk output stream that can only output to a stream.
LandingPadInst * getLandingPadInst()
reverse_iterator rbegin()
const Module * getModule() const
Return the module owning the function this basic block belongs to, or nullptr if the function does no...
void removeFromParent()
This method unlinks 'this' from the containing basic block, but does not delete it.
const Instruction * getFirstNonPHI() const
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
const CallInst * getPostdominatingDeoptimizeCall() const
Returns the call instruction calling @llvm.experimental.deoptimize that is present either in current ...
void renumberInstructions()
Renumber instructions and mark the ordering as valid.
bool isEntryBlock() const
Return true if this is the entry block of the containing function.
bool hasAddressTaken() const
Returns true if there are any uses of this basic block other than direct branches,...
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
void removeFromParent()
Unlink 'this' from the containing function, but do not delete it.
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
std::optional< uint64_t > getIrrLoopHeaderWeight() const
This is an important class for using LLVM in a threaded context.
bool isLegalToHoistInto() const
Return true if it is legal to hoist instructions into this block.
const_reverse_iterator rend() const
bool isInstrOrderValid() const
Returns true if the Order field of child Instructions is valid.
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
phi_iterator_impl(const phi_iterator_impl< PHINodeU, BBIteratorU > &Arg)
BasicBlock & operator=(const BasicBlock &)=delete
phi_iterator_impl & operator++()
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
<%struct.s * > cast struct s *S to sbyte *< sbyte * > sbyte uint cast struct s *agg result to sbyte *< sbyte * > sbyte uint cast struct s *memtmp to sbyte *< sbyte * > sbyte uint ret void llc ends up issuing two memcpy or custom lower memcpy(of small size) to be ldmia/stmia. I think option 2 is better but the current register allocator cannot allocate a chunk of registers at a time. A feasible temporary solution is to use specific physical registers at the lowering time for small(<
@ BasicBlock
Various leaf nodes.
print Print MemDeps of function
A Module instance is used to store all the information related to an LLVM module.
static bool classof(const Value *V)
Methods for support type inquiry through isa, cast, and dyn_cast.
const_reverse_iterator rbegin() const
CallInst * getTerminatingMustTailCall()
The address of a basic block.
void moveAfter(BasicBlock *MovePos)
Unlink this basic block from its current function and insert it right after MovePos in the function M...
BasicBlock * getUniquePredecessor()
const BasicBlock * getUniquePredecessor() const
Return the predecessor of this block if it has a unique predecessor block.
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
Machine Check Debug Module
BasicBlock::iterator erase(BasicBlock::iterator FromIt, BasicBlock::iterator ToIt)
Erases a range of instructions from FromIt to (not including) ToIt.
void validateInstrOrdering() const
Asserts that instruction order numbers are marked invalid, or that they are in ascending order.
void dropAllReferences()
Cause all subinstructions to "let go" of all the references that said subinstructions are maintaining...
InstListType::const_reverse_iterator const_reverse_iterator
const Instruction & front() const
phi_iterator_impl()=default
LLVMContext & getContext() const
Get the context in which this basic block lives.
Instruction * getTerminator()
void replacePhiUsesWith(BasicBlock *Old, BasicBlock *New)
Update all phi nodes in this basic block to refer to basic block New instead of basic block Old.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
BasicBlock * getSinglePredecessor()
Iterator to walk just the phi nodes in the basic block.
Instruction * getFirstNonPHI()
Iterator for intrusive lists based on ilist_node.
bool isEHPad() const
Return true if the instruction is a variety of EH-block.
void insertInto(Function *Parent, BasicBlock *InsertBefore=nullptr)
Insert unlinked basic block into a function.
const Instruction * getFirstNonPHIOrDbgOrLifetime(bool SkipPseudoOp=true) const
Returns a pointer to the first instruction in this block that is not a PHINode, a debug intrinsic,...
void splice(BasicBlock::iterator ToIt, BasicBlock *FromBB, BasicBlock::iterator FromIt)
Transfer one instruction from FromBB at FromIt to this basic block at ToIt.
const Instruction & back() const
InstListType::reverse_iterator reverse_iterator
void moveBefore(BasicBlock *MovePos)
Unlink this basic block from its current function and insert it into the function that MovePos lives ...
bool operator==(const phi_iterator_impl &Arg) const
A range adaptor for a pair of iterators.
const Instruction * getFirstNonPHIOrDbg(bool SkipPseudoOp=true) const
Returns a pointer to the first instruction in this block that is not a PHINode or a debug intrinsic,...
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
void removePredecessor(BasicBlock *Pred, bool KeepOneInputPHIs=false)
Update PHI nodes in this BasicBlock before removal of predecessor Pred.
BasicBlock * splitBasicBlock(Instruction *I, const Twine &BBName="", bool Before=false)
#define BEGIN_TWO_BYTE_PACK()
const LandingPadInst * getLandingPadInst() const
Return the landingpad instruction associated with the landing pad.
BasicBlock * splitBasicBlockBefore(Instruction *I, const Twine &BBName="")
This class represents a function call, abstracting a target machine's calling convention.
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
iterator getFirstInsertionPt()
CallInst * getTerminatingDeoptimizeCall()
const CallInst * getTerminatingMustTailCall() const
Returns the call instruction marked 'musttail' prior to the terminating return instruction of this ba...
const_iterator getFirstNonPHIOrDbgOrAlloca() const
Returns an iterator to the first instruction in this block that is not a PHINode, a debug intrinsic,...
bool isEHPad() const
Return true if this basic block is an exception handling block.
const_iterator end() const
LLVM Value Representation.
InstListType::const_iterator const_iterator