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;
113 return const_cast<Module *
>(
120 if (InstList.empty() || !InstList.back().isTerminator())
122 return &InstList.back();
291 bool ShouldPreserveUseListOrder =
false,
292 bool IsForDebug =
false)
const;
307 inline size_t size()
const {
return InstList.size(); }
308 inline bool empty()
const {
return InstList.empty(); }
315 template <
typename PHINodeT = PHINode,
typename BBIteratorT = iterator>
318 std::forward_iterator_tag, PHINodeT> {
331 template <
typename PHINodeU,
typename BBIteratorU,
332 typename = std::enable_if_t<
333 std::is_convertible<PHINodeU *, PHINodeT *>::value>>
341 using phi_iterator_impl::iterator_facade_base::operator++;
343 assert(PN &&
"Cannot increment the end iterator!");
344 PN = dyn_cast<PHINodeT>(std::next(BBIteratorT(PN)));
369 return &BasicBlock::InstList;
377 return V->
getValueID() == Value::BasicBlockVal;
419 bool Before =
false);
421 bool Before =
false) {
450 return getBasicBlockBits().BlockAddressRefCount != 0;
492 return getBasicBlockBits().InstrOrderValid;
498 BasicBlockBits
Bits = getBasicBlockBits();
499 Bits.InstrOrderValid =
false;
500 setBasicBlockBits(
Bits);
517 #if defined(_AIX) && (!defined(__GNUC__) || defined(__clang__))
520 #define BEGIN_TWO_BYTE_PACK() _Pragma("pack(2)")
521 #define END_TWO_BYTE_PACK() _Pragma("pack(pop)")
523 #define BEGIN_TWO_BYTE_PACK()
524 #define END_TWO_BYTE_PACK()
529 struct BasicBlockBits {
530 unsigned short BlockAddressRefCount : 15;
531 unsigned short InstrOrderValid : 1;
535 #undef BEGIN_TWO_BYTE_PACK
536 #undef END_TWO_BYTE_PACK
539 BasicBlockBits getBasicBlockBits()
const {
540 static_assert(
sizeof(BasicBlockBits) ==
sizeof(
unsigned short),
541 "too many bits for Value::SubclassData");
543 BasicBlockBits AsBits;
544 memcpy(&AsBits, &ValueData,
sizeof(AsBits));
549 void setBasicBlockBits(BasicBlockBits AsBits) {
560 void AdjustBlockAddressRefCount(
int Amt) {
561 BasicBlockBits
Bits = getBasicBlockBits();
562 Bits.BlockAddressRefCount += Amt;
563 setBasicBlockBits(
Bits);
564 assert(
Bits.BlockAddressRefCount < 255 &&
"Refcount wrap-around");
569 void setValueSubclassData(
unsigned short D) {
589 #endif // LLVM_IR_BASICBLOCK_H
const CallInst * getTerminatingDeoptimizeCall() const
Returns the call instruction calling @llvm.experimental.deoptimize prior to the terminating return in...
static InstListType BasicBlock::* getSublistAccess(Instruction *)
Returns a pointer to a member of the instruction list.
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
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.
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.
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...
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,...
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")
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
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()
InstListType & getInstList()
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,...
const Instruction & back() const
const InstListType & getInstList() const
Return the underlying instruction list container.
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 ...
This class provides a symbol table of name/value pairs.
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()
Optional< uint64_t > getIrrLoopHeaderWeight() const
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.
iterator getFirstInsertionPt()
CallInst * getTerminatingDeoptimizeCall()
const CallInst * getTerminatingMustTailCall() const
Returns the call instruction marked 'musttail' prior to the terminating return instruction of this ba...
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