1//===- llvm/BasicBlock.h - Represent a basic block in the VM ----*- C++ -*-===// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7//===----------------------------------------------------------------------===// 9// This file contains the declaration of the BasicBlock class. 11//===----------------------------------------------------------------------===// 13#ifndef LLVM_IR_BASICBLOCK_H 14#define LLVM_IR_BASICBLOCK_H 33classAssemblyAnnotationWriter;
42classDbgVariableRecord;
45/// LLVM Basic Block Representation 47/// This represents a single basic block in LLVM. A basic block is simply a 48/// container of instructions that execute sequentially. Basic blocks are Values 49/// because they are referenced by instructions such as branches and switch 50/// tables. The type of a BasicBlock is "Type::LabelTy" because the basic block 51/// represents a label to which a branch can jump. 53/// A well formed basic block is formed of a list of non-terminating 54/// instructions followed by a single terminator instruction. Terminator 55/// instructions may not occur in the middle of basic blocks, and must terminate 56/// the blocks. The BasicBlock class allows malformed basic blocks to occur 57/// because it may be useful in the intermediate stage of constructing or 58/// modifying a program. However, the verifier will ensure that basic blocks are 65 /// Flag recording whether or not this block stores debug-info in the form 66 /// of intrinsic instructions (false) or non-instruction records (true). 70// Allow Function to renumber blocks. 72 /// Per-function unique number. 82 /// Attach a DbgMarker to the given instruction. Enables the storage of any 83 /// debug-info at this position in the program. 87 /// Convert variable location debugging information stored in dbg.value 88 /// intrinsics into DbgMarkers / DbgRecords. Deletes all dbg.values in 89 /// the process and sets IsNewDbgInfoFormat = true. Only takes effect if 90 /// the UseNewDbgInfoFormat LLVM command line option is given. 93 /// Convert variable location debugging information stored in DbgMarkers and 94 /// DbgRecords into the dbg.value intrinsic representation. Sets 95 /// IsNewDbgInfoFormat = false. 98 /// Ensure the block is in "old" dbg.value format (\p NewFlag == false) or 99 /// in the new format (\p NewFlag == true), converting to the desired format 105assert(
getParent() &&
"only basic blocks in functions have valid numbers");
109 /// Record that the collection of DbgRecords in \p M "trails" after the last 110 /// instruction of this block. These are equivalent to dbg.value intrinsics 111 /// that exist at the end of a basic block with no terminator (a transient 112 /// state that occurs regularly). 115 /// Fetch the collection of DbgRecords that "trail" after the last instruction 116 /// of this block, see \ref setTrailingDbgRecords. If there are none, returns 120 /// Delete any trailing DbgRecords at the end of this block, see 121 /// \ref setTrailingDbgRecords. 126 /// Return the DbgMarker for the position given by \p It, so that DbgRecords 127 /// can be inserted there. This will either be nullptr if not present, a 128 /// DbgMarker, or TrailingDbgRecords if It is end(). 131 /// Return the DbgMarker for the position that comes after \p I. \see 132 /// BasicBlock::getMarker, this can be nullptr, a DbgMarker, or 133 /// TrailingDbgRecords if there is no next instruction. 136 /// Insert a DbgRecord into a block at the position given by \p I. 139 /// Insert a DbgRecord into a block at the position given by \p Here. 142 /// Eject any debug-info trailing at the end of a block. DbgRecords can 143 /// transiently be located "off the end" of a block if the blocks terminator 144 /// is temporarily removed. Once a terminator is re-inserted this method will 145 /// move such DbgRecords back to the right place (ahead of the terminator). 148 /// In rare circumstances instructions can be speculatively removed from 149 /// blocks, and then be re-inserted back into that position later. When this 150 /// happens in RemoveDIs debug-info mode, some special patching-up needs to 151 /// occur: inserting into the middle of a sequence of dbg.value intrinsics 152 /// does not have an equivalent with DbgRecords. 154 std::optional<DbgRecord::self_iterator> Pos);
161 /// If the function parameter is specified, the basic block is automatically 162 /// inserted at either the end of the function (if InsertBefore is null), or 163 /// before the specified basic block. 173 /// Get the context in which this basic block lives. 176 /// Instruction iterators... 182// These functions and classes need access to the instruction list. 190 ilist_iterator_bits<true>,
191 ilist_parent<BasicBlock>>;
193// Friendly methods that need to access us for the maintenence of 194// debug-info attachments. 199 InstListType::iterator InsertPos);
201 InstListType::iterator I,
205 const Instruction *From, std::optional<DbgRecord::self_iterator> FromHere,
208 /// Creates a new BasicBlock. 210 /// If the Parent parameter is specified, the basic block is automatically 211 /// inserted at either the end of the function (if InsertBefore is 0), or 212 /// before the specified basic block. 214 Function *Parent = nullptr,
215 BasicBlock *InsertBefore = nullptr) {
219 /// Return the enclosing method, or null if none. 223 /// Return the module owning the function this basic block belongs to, or 224 /// nullptr if the function does not have a module. 226 /// Note: this is undefined behavior if the block does not have a parent. 229returnconst_cast<Module *
>(
233 /// Get the data layout of the module this basic block belongs to. 235 /// Requires the basic block to have a parent module. 238 /// Returns the terminator instruction if the block is well formed or null 239 /// if the block is not well formed. 241if (InstList.empty() || !InstList.back().isTerminator())
243return &InstList.back();
250 /// Returns the call instruction calling \@llvm.experimental.deoptimize 251 /// prior to the terminating return instruction of this basic block, if such 252 /// a call is present. Otherwise, returns null. 259 /// Returns the call instruction calling \@llvm.experimental.deoptimize 260 /// that is present either in current basic block or in block that is a unique 261 /// successor to current block, if such call is present. Otherwise, returns null. 268 /// Returns the call instruction marked 'musttail' prior to the terminating 269 /// return instruction of this basic block, if such a call is present. 270 /// Otherwise, returns null. 277 /// Returns a pointer to the first instruction in this block that is not a 278 /// PHINode instruction. 280 /// When adding instructions to the beginning of the basic block, they should 281 /// be added before the returned value, not before the first instruction, 282 /// which might be PHI. Returns 0 is there's no non-PHI instruction. 289 /// Iterator returning form of getFirstNonPHI. Installed as a placeholder for 290 /// the RemoveDIs project that will eventually remove debug intrinsics. 299 /// Returns a pointer to the first instruction in this block that is not a 300 /// PHINode or a debug intrinsic, or any pseudo operation if \c SkipPseudoOp 310 /// Returns a pointer to the first instruction in this block that is not a 311 /// PHINode, a debug intrinsic, or a lifetime intrinsic, or any pseudo 312 /// operation if \c SkipPseudoOp is true. 322 /// Returns an iterator to the first instruction in this block that is 323 /// suitable for inserting a non-PHI instruction. 325 /// In particular, it skips all PHIs and LandingPad instructions. 332 /// Returns an iterator to the first instruction in this block that is 333 /// not a PHINode, a debug intrinsic, a static alloca or any pseudo operation. 341 /// Returns the first potential AsynchEH faulty instruction 342 /// currently it checks for loads/stores (which may dereference a null 343 /// pointer) and calls/invokes (which may propagate exceptions) 350 /// Return a const iterator range over the instructions in the block, skipping 351 /// any debug instructions. Skip any pseudo operations as well if \c 352 /// SkipPseudoOp is true. 357 /// Return an iterator range over the instructions in the block, skipping any 358 /// debug instructions. Skip and any pseudo operations as well if \c 359 /// SkipPseudoOp is true. 364 /// Return the size of the basic block ignoring debug instructions 369 /// Unlink 'this' from the containing function, but do not delete it. 372 /// Unlink 'this' from the containing function and delete it. 374// \returns an iterator pointing to the element after the erased one. 377 /// Unlink this basic block from its current function and insert it into 378 /// the function that \p MovePos lives in, right before \p MovePos. 384 /// Unlink this basic block from its current function and insert it 385 /// right after \p MovePos in the function \p MovePos lives in. 388 /// Insert unlinked basic block into a function. 390 /// Inserts an unlinked basic block into \c Parent. If \c InsertBefore is 391 /// provided, inserts before that basic block, otherwise inserts at the end. 393 /// \pre \a getParent() is \c nullptr. 396 /// Return the predecessor of this block if it has a single predecessor 397 /// block. Otherwise return a null pointer. 404 /// Return the predecessor of this block if it has a unique predecessor 405 /// block. Otherwise return a null pointer. 407 /// Note that unique predecessor doesn't mean single edge, there can be 408 /// multiple edges from the unique predecessor to this block (for example a 409 /// switch statement with multiple cases having the same destination). 416 /// Return true if this block has exactly N predecessors. 419 /// Return true if this block has N predecessors or more. 422 /// Return the successor of this block if it has a single successor. 423 /// Otherwise return a null pointer. 425 /// This method is analogous to getSinglePredecessor above. 432 /// Return the successor of this block if it has a unique successor. 433 /// Otherwise return a null pointer. 435 /// This method is analogous to getUniquePredecessor above. 442 /// Print the basic block to an output stream with an optional 443 /// AssemblyAnnotationWriter. 445bool ShouldPreserveUseListOrder =
false,
446bool IsForDebug =
false)
const;
448//===--------------------------------------------------------------------===// 449 /// Instruction iterator methods 453// Set the head-inclusive bit to indicate that this iterator includes 454// any debug-info at the start of the block. This is a no-op unless the 455// appropriate CMake flag is set. 472inlinesize_tsize()
const{
return InstList.size(); }
473inlineboolempty()
const{
return InstList.empty(); }
479 /// Iterator to walk just the phi nodes in the basic block. 480template <
typename PHINodeT = PHINode,
typename BBIteratorT = iterator>
483 std::forward_iterator_tag, PHINodeT> {
491// Allow default construction to build variables, but this doesn't build 495// Allow conversion between instantiations where valid. 496template <
typename PHINodeU,
typename BBIteratorU,
497typename = std::enable_if_t<
498 std::is_convertible<PHINodeU *, PHINodeT *>::value>>
506usingphi_iterator_impl::iterator_facade_base::operator++;
508assert(PN &&
"Cannot increment the end iterator!");
509 PN = dyn_cast<PHINodeT>(std::next(BBIteratorT(PN)));
517 /// Returns a range that iterates over the phis in the basic block. 519 /// Note that this cannot be used with basic blocks that have no terminator. 526 /// Return the underlying instruction list container. 527 /// This is deliberately private because we have implemented an adequate set 528 /// of functions to modify the list, including BasicBlock::splice(), 529 /// BasicBlock::erase(), Instruction::insertInto() etc. 530constInstListType &getInstList()
const{
return InstList; }
533 /// Returns a pointer to a member of the instruction list. 534 /// This is private on purpose, just like `getInstList()`. 535staticInstListType BasicBlock::*getSublistAccess(Instruction *) {
536return &BasicBlock::InstList;
539 /// Dedicated function for splicing debug-info: when we have an empty 540 /// splice (i.e. zero instructions), the caller may still intend any 541 /// debug-info in between the two "positions" to be spliced. 546 /// Perform any debug-info specific maintenence for the given splice 547 /// activity. In the DbgRecord debug-info representation, debug-info is not 548 /// in instructions, and so it does not automatically move from one block 558 /// Returns a pointer to the symbol table if one exists. 561 /// Methods for support type inquiry through isa, cast, and dyn_cast. 563return V->getValueID() == Value::BasicBlockVal;
566 /// Cause all subinstructions to "let go" of all the references that said 567 /// subinstructions are maintaining. 569 /// This allows one to 'delete' a whole class at a time, even though there may 570 /// be circular references... first all references are dropped, and all use 571 /// counts go to zero. Then everything is delete'd for real. Note that no 572 /// operations are valid on an object that has "dropped all references", 573 /// except operator delete. 576 /// Update PHI nodes in this BasicBlock before removal of predecessor \p Pred. 577 /// Note that this function does not actually remove the predecessor. 579 /// If \p KeepOneInputPHIs is true then don't remove PHIs that are left with 580 /// zero or one incoming values, and don't simplify PHIs with all incoming 586 /// Split the basic block into two basic blocks at the specified instruction. 588 /// If \p Before is true, splitBasicBlockBefore handles the 589 /// block splitting. Otherwise, execution proceeds as described below. 591 /// Note that all instructions BEFORE the specified iterator 592 /// stay as part of the original basic block, an unconditional branch is added 593 /// to the original BB, and the rest of the instructions in the BB are moved 594 /// to the new BB, including the old terminator. The newly formed basic block 595 /// is returned. This function invalidates the specified iterator. 597 /// Note that this only works on well formed basic blocks (must have a 598 /// terminator), and \p 'I' must not be the end of instruction list (which 599 /// would cause a degenerate basic block to be formed, having a terminator 600 /// inside of the basic block). 602 /// Also note that this doesn't preserve any passes. To split blocks while 603 /// keeping loop information consistent, use the SplitBlock utility function. 611 /// Split the basic block into two basic blocks at the specified instruction 612 /// and insert the new basic blocks as the predecessor of the current block. 614 /// This function ensures all instructions AFTER and including the specified 615 /// iterator \p I are part of the original basic block. All Instructions 616 /// BEFORE the iterator \p I are moved to the new BB and an unconditional 617 /// branch is added to the new BB. The new basic block is returned. 619 /// Note that this only works on well formed basic blocks (must have a 620 /// terminator), and \p 'I' must not be the end of instruction list (which 621 /// would cause a degenerate basic block to be formed, having a terminator 622 /// inside of the basic block). \p 'I' cannot be a iterator for a PHINode 623 /// with multiple incoming blocks. 625 /// Also note that this doesn't preserve any passes. To split blocks while 626 /// keeping loop information consistent, use the SplitBlockBefore utility 633 /// Transfer all instructions from \p FromBB to this basic block at \p ToIt. 638 /// Transfer one instruction from \p FromBB at \p FromIt to this basic block 642auto FromItNext = std::next(FromIt);
643// Single-element splice is a noop if destination == source. 644if (ToIt == FromIt || ToIt == FromItNext)
646splice(ToIt, FromBB, FromIt, FromItNext);
649 /// Transfer a range of instructions that belong to \p FromBB from \p 650 /// FromBeginIt to \p FromEndIt, to this basic block at \p ToIt. 655 /// Erases a range of instructions from \p FromIt to (not including) \p ToIt. 656 /// \Returns \p ToIt. 659 /// Returns true if there are any uses of this basic block other than 660 /// direct branches, switches, etc. to it. 662return getBasicBlockBits().BlockAddressRefCount != 0;
665 /// Update all phi nodes in this basic block to refer to basic block \p New 666 /// instead of basic block \p Old. 669 /// Update all phi nodes in this basic block's successors to refer to basic 670 /// block \p New instead of basic block \p Old. 673 /// Update all phi nodes in this basic block's successors to refer to basic 674 /// block \p New instead of to it. 677 /// Return true if this basic block is an exception handling block. 680 /// Return true if this basic block is a landing pad. 682 /// Being a ``landing pad'' means that the basic block is the destination of 683 /// the 'unwind' edge of an invoke instruction. 686 /// Return the landingpad instruction associated with the landing pad. 693 /// Return true if it is legal to hoist instructions into this block. 696 /// Return true if this is the entry block of the containing function. 697 /// This method can only be used on blocks that have a parent function. 702 /// Returns true if the Order field of child Instructions is valid. 704return getBasicBlockBits().InstrOrderValid;
707 /// Mark instruction ordering invalid. Done on every instruction insert. 710 BasicBlockBits Bits = getBasicBlockBits();
711 Bits.InstrOrderValid =
false;
712 setBasicBlockBits(Bits);
715 /// Renumber instructions and mark the ordering as valid. 718 /// Asserts that instruction order numbers are marked invalid, or that they 719 /// are in ascending order. This is constant time if the ordering is invalid, 720 /// and linear in the number of instructions if the ordering is valid. Callers 721 /// should be careful not to call this in ways that make common operations 722 /// O(n^2). For example, it takes O(n) time to assign order numbers to 723 /// instructions, so the order should be validated no more than once after 724 /// each ordering to ensure that transforms have the same algorithmic 725 /// complexity when asserts are enabled as when they are disabled. 729#if defined(_AIX) && (!defined(__GNUC__) || defined(__clang__)) 730// Except for GCC; by default, AIX compilers store bit-fields in 4-byte words 731// and give the `pack` pragma push semantics. 732#define BEGIN_TWO_BYTE_PACK() _Pragma("pack(2)")
733#define END_TWO_BYTE_PACK() _Pragma("pack(pop)")
735#define BEGIN_TWO_BYTE_PACK() 736#define END_TWO_BYTE_PACK() 740 /// Bitfield to help interpret the bits in Value::SubclassData. 741 struct BasicBlockBits {
742unsignedshort BlockAddressRefCount : 15;
743unsignedshort InstrOrderValid : 1;
747#undef BEGIN_TWO_BYTE_PACK 748#undef END_TWO_BYTE_PACK 750 /// Safely reinterpret the subclass data bits to a more useful form. 751 BasicBlockBits getBasicBlockBits()
const{
752static_assert(
sizeof(BasicBlockBits) ==
sizeof(
unsignedshort),
753"too many bits for Value::SubclassData");
755 BasicBlockBits AsBits;
756 memcpy(&AsBits, &ValueData,
sizeof(AsBits));
760 /// Reinterpret our subclass bits and store them back into Value. 761void setBasicBlockBits(BasicBlockBits AsBits) {
763 memcpy(&
D, &AsBits,
sizeof(
D));
767 /// Increment the internal refcount of the number of BlockAddresses 768 /// referencing this BasicBlock by \p Amt. 770 /// This is almost always 0, sometimes one possibly, but almost never 2, and 771 /// inconceivably 3 or more. 772void AdjustBlockAddressRefCount(
int Amt) {
773 BasicBlockBits
Bits = getBasicBlockBits();
774Bits.BlockAddressRefCount += Amt;
775 setBasicBlockBits(Bits);
776assert(
Bits.BlockAddressRefCount < 255 &&
"Refcount wrap-around");
779 /// Shadow Value::setValueSubclassData with a private forwarding method so 780 /// that any future subclasses cannot accidentally use it. 781void setValueSubclassData(
unsignedshortD) {
786// Create wrappers for C Binding types (see CBindingWrapping.h). 789/// Advance \p It while it points to a debug instruction and return the result. 790/// This assumes that \p It is not at the end of a block. 794/// In release builds, this is a no-op. For !NDEBUG builds, the checks are 795/// implemented in the .cpp file to avoid circular header deps. 799// Specialize DenseMapInfo for iterators, so that ththey can be installed into 800// maps and sets. The iterator is made up of its node pointer, and the 801// debug-info "head" bit. 815reinterpret_cast<void *
>(It.getNodePtr())) ^
825}
// end namespace llvm 827#endif// LLVM_IR_BASICBLOCK_H static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)
This file defines the DenseMap class.
Machine Check Debug Module
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
#define END_TWO_BYTE_PACK()
#define BEGIN_TWO_BYTE_PACK()
Iterator to walk just the phi nodes in the basic block.
bool operator==(const phi_iterator_impl &Arg) const
phi_iterator_impl(const phi_iterator_impl< PHINodeU, BBIteratorU > &Arg)
PHINodeT & operator*() const
phi_iterator_impl()=default
phi_iterator_impl & operator++()
LLVM Basic Block Representation.
BasicBlock::iterator erase(BasicBlock::iterator FromIt, BasicBlock::iterator ToIt)
Erases a range of instructions from FromIt to (not including) ToIt.
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...
BasicBlock(const BasicBlock &)=delete
unsigned getNumber() const
Instruction * getFirstMayFaultInst()
iterator begin()
Instruction iterator methods.
void deleteTrailingDbgRecords()
Delete any trailing DbgRecords at the end of this block, see setTrailingDbgRecords.
iterator_range< const_phi_iterator > phis() const
Returns a range that iterates over the phis in the basic block.
const_iterator begin() const
const LandingPadInst * getLandingPadInst() const
Return the landingpad instruction associated with the landing pad.
void setTrailingDbgRecords(DbgMarker *M)
Record that the collection of DbgRecords in M "trails" after the last instruction of this block.
const_iterator getFirstInsertionPt() const
Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI i...
reverse_iterator rbegin()
static bool classof(const Value *V)
Methods for support type inquiry through isa, cast, and dyn_cast.
InstListType::iterator getFirstNonPHIOrDbgOrLifetime(bool SkipPseudoOp=true)
void renumberInstructions()
Renumber instructions and mark the ordering as valid.
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.
InstListType::iterator getFirstNonPHIIt()
DbgMarker * createMarker(Instruction *I)
Attach a DbgMarker to the given instruction.
BasicBlock * splitBasicBlock(Instruction *I, const Twine &BBName="", bool Before=false)
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...
bool hasAddressTaken() const
Returns true if there are any uses of this basic block other than direct branches,...
InstListType::const_iterator getFirstNonPHIIt() const
Iterator returning form of getFirstNonPHI.
void insertDbgRecordBefore(DbgRecord *DR, InstListType::iterator Here)
Insert a DbgRecord into a block at the position given by Here.
BasicBlock * splitBasicBlockBefore(Instruction *I, const Twine &BBName="")
void invalidateOrders()
Mark instruction ordering invalid. Done on every instruction insert.
friend void Instruction::removeFromParent()
void convertToNewDbgValues()
Convert variable location debugging information stored in dbg.value intrinsics into DbgMarkers / DbgR...
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.
InstListType::const_iterator const_iterator
void setIsNewDbgInfoFormat(bool NewFlag)
Ensure the block is in "old" dbg.value format (NewFlag == false) or in the new format (NewFlag == tru...
const Instruction * getFirstNonPHI() const
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
BasicBlock * getUniqueSuccessor()
const Instruction & front() const
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
BasicBlock * getSingleSuccessor()
friend BasicBlock::iterator Instruction::eraseFromParent()
void setNewDbgInfoFormatFlag(bool NewFlag)
bool isEntryBlock() const
Return true if this is the entry block of the containing function.
ValueSymbolTable * getValueSymbolTable()
Returns a pointer to the symbol table if one exists.
BasicBlock * getUniquePredecessor()
void moveAfter(BasicBlock *MovePos)
Unlink this basic block from its current function and insert it right after MovePos in the function M...
InstListType::const_iterator getFirstNonPHIOrDbg(bool SkipPseudoOp=true) const
Returns a pointer to the first instruction in this block that is not a PHINode or a debug intrinsic,...
bool hasNPredecessors(unsigned N) const
Return true if this block has exactly N predecessors.
BasicBlock * splitBasicBlock(iterator I, const Twine &BBName="", bool Before=false)
Split the basic block into two basic blocks at the specified instruction.
BasicBlock * getSinglePredecessor()
void convertFromNewDbgValues()
Convert variable location debugging information stored in DbgMarkers and DbgRecords into the dbg....
const BasicBlock * getUniqueSuccessor() const
Return the successor of this block if it has a unique successor.
const BasicBlock * getSinglePredecessor() const
Return the predecessor of this block if it has a single predecessor block.
std::optional< uint64_t > getIrrLoopHeaderWeight() const
void dumpDbgValues() const
const CallInst * getTerminatingDeoptimizeCall() const
Returns the call instruction calling @llvm.experimental.deoptimize prior to the terminating return in...
InstListType::reverse_iterator reverse_iterator
friend void Instruction::moveBeforeImpl(BasicBlock &BB, InstListType::iterator I, bool Preserve)
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.
const BasicBlock * getUniquePredecessor() const
Return the predecessor of this block if it has a unique predecessor block.
const BasicBlock * getSingleSuccessor() const
Return the successor of this block if it has a single successor.
void flushTerminatorDbgRecords()
Eject any debug-info trailing at the end of a block.
void splice(BasicBlock::iterator ToIt, BasicBlock *FromBB, BasicBlock::iterator FromIt)
Transfer one instruction from FromBB at FromIt to this basic block at ToIt.
const Function * getParent() const
Return the enclosing method, or null if none.
InstListType::iterator getFirstNonPHIOrDbg(bool SkipPseudoOp=true)
const DataLayout & getDataLayout() const
Get the data layout of the module this basic block belongs to.
const_reverse_iterator rend() const
void insertDbgRecordAfter(DbgRecord *DR, Instruction *I)
Insert a DbgRecord into a block at the position given by I.
void validateInstrOrdering() const
Asserts that instruction order numbers are marked invalid, or that they are in ascending order.
DbgMarker * getMarker(InstListType::iterator It)
Return the DbgMarker for the position given by It, so that DbgRecords can be inserted there.
filter_iterator< BasicBlock::const_iterator, std::function< bool(constInstruction &)> >::difference_type sizeWithoutDebug() const
Return the size of the basic block ignoring debug instructions.
InstListType::iterator iterator
Instruction iterators...
Instruction * getFirstNonPHI()
LLVMContext & getContext() const
Get the context in which this basic block lives.
CallInst * getPostdominatingDeoptimizeCall()
const_iterator getFirstNonPHIOrDbgOrAlloca() const
Returns an iterator to the first instruction in this block that is not a PHINode, a debug intrinsic,...
SymbolTableList< Instruction, ilist_iterator_bits< true >, ilist_parent< BasicBlock > > InstListType
Instruction * getTerminator()
BasicBlock & operator=(const BasicBlock &)=delete
iterator getFirstNonPHIOrDbgOrAlloca()
bool IsNewDbgInfoFormat
Flag recording whether or not this block stores debug-info in the form of intrinsic instructions (fal...
CallInst * getTerminatingDeoptimizeCall()
void dropAllReferences()
Cause all subinstructions to "let go" of all the references that said subinstructions are maintaining...
void reinsertInstInDbgRecords(Instruction *I, std::optional< DbgRecord::self_iterator > Pos)
In rare circumstances instructions can be speculatively removed from blocks, and then be re-inserted ...
void moveBefore(BasicBlock *MovePos)
Unlink this basic block from its current function and insert it into the function that MovePos lives ...
InstListType::const_iterator getFirstNonPHIOrDbgOrLifetime(bool SkipPseudoOp=true) const
Returns a pointer to the first instruction in this block that is not a PHINode, a debug intrinsic,...
bool isLandingPad() const
Return true if this basic block is a landing pad.
InstListType::const_reverse_iterator const_reverse_iterator
bool isEHPad() const
Return true if this basic block is an exception handling block.
DbgMarker * getTrailingDbgRecords()
Fetch the collection of DbgRecords that "trail" after the last instruction of this block,...
CallInst * getTerminatingMustTailCall()
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...
bool canSplitPredecessors() const
const_iterator end() const
const CallInst * getTerminatingMustTailCall() const
Returns the call instruction marked 'musttail' prior to the terminating return instruction of this ba...
friend BasicBlock::iterator Instruction::insertInto(BasicBlock *BB, BasicBlock::iterator It)
bool isLegalToHoistInto() const
Return true if it is legal to hoist instructions into this block.
bool hasNPredecessorsOrMore(unsigned N) const
Return true if this block has N predecessors or more.
bool isInstrOrderValid() const
Returns true if the Order field of child Instructions is valid.
const CallInst * getPostdominatingDeoptimizeCall() const
Returns the call instruction calling @llvm.experimental.deoptimize that is present either in current ...
DbgMarker * getNextMarker(Instruction *I)
Return the DbgMarker for the position that comes after I.
const Instruction * getFirstMayFaultInst() const
Returns the first potential AsynchEH faulty instruction currently it checks for loads/stores (which m...
void splice(BasicBlock::iterator ToIt, BasicBlock *FromBB)
Transfer all instructions from FromBB to this basic block at ToIt.
const_reverse_iterator rbegin() const
LandingPadInst * getLandingPadInst()
const Instruction & back() const
const Module * getModule() const
Return the module owning the function this basic block belongs to, or nullptr if the function does no...
iterator getFirstInsertionPt()
void removePredecessor(BasicBlock *Pred, bool KeepOneInputPHIs=false)
Update PHI nodes in this BasicBlock before removal of predecessor Pred.
The address of a basic block.
This class represents a function call, abstracting a target machine's calling convention.
A parsed version of the target data layout string in and methods for querying it.
Per-instruction record of debug-info.
Base class for non-instruction debug metadata records that have positions within IR.
void removeFromParent()
This method unlinks 'this' from the containing basic block, but does not delete it.
iterator_range< simple_ilist< DbgRecord >::iterator > cloneDebugInfoFrom(const Instruction *From, std::optional< simple_ilist< DbgRecord >::iterator > FromHere=std::nullopt, bool InsertAtHead=false)
Clone any debug-info attached to From onto this instruction.
void insertBefore(Instruction *InsertPos)
Insert an unlinked instruction into a basic block immediately before the specified instruction.
InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
void insertAfter(Instruction *InsertPos)
Insert an unlinked instruction into a basic block immediately after the specified instruction.
InstListType::iterator insertInto(BasicBlock *ParentBB, InstListType::iterator It)
Inserts an unlinked instruction into ParentBB at position It and returns the iterator of the inserted...
This is an important class for using LLVM in a threaded context.
The landingpad instruction holds all of the information necessary to generate correct exception handl...
A Module instance is used to store all the information related to an LLVM module.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM Value Representation.
unsigned short getSubclassDataFromValue() const
void setValueSubclassData(unsigned short D)
Specialization of filter_iterator_base for forward iteration only.
self_iterator getIterator()
An ilist node that can access its parent list.
base_list_type::const_reverse_iterator const_reverse_iterator
base_list_type::reverse_iterator reverse_iterator
base_list_type::const_iterator const_iterator
base_list_type::iterator iterator
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
struct LLVMOpaqueBasicBlock * LLVMBasicBlockRef
Represents a basic block of instructions in LLVM IR.
This file defines classes to implement an intrusive doubly linked list class (i.e.
This file defines the ilist_node class template, which is a convenient base class for creating classe...
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
BasicBlock::iterator skipDebugIntrinsics(BasicBlock::iterator It)
Advance It while it points to a debug instruction and return the result.
static BasicBlock::iterator getEmptyKey()
static unsigned getHashValue(const BasicBlock::iterator &It)
static bool isEqual(const BasicBlock::iterator &LHS, const BasicBlock::iterator &RHS)
static BasicBlock::iterator getTombstoneKey()
An information struct used to provide DenseMap with the various necessary components for a given valu...
Option to add extra bits to the ilist_iterator.
Option to add a pointer to this list's owner in every node.