1//===- llvm/CodeGen/MachineBasicBlock.h -------------------------*- 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// Collect the sequence of machine instructions for a basic block. 11//===----------------------------------------------------------------------===// 13#ifndef LLVM_CODEGEN_MACHINEBASICBLOCK_H 14#define LLVM_CODEGEN_MACHINEBASICBLOCK_H 35classMachineDomTreeUpdater;
38classModuleSlotTracker;
45classTargetRegisterClass;
46classTargetRegisterInfo;
47template <
typename IRUnitT,
typename... ExtraArgTs>
classAnalysisManager;
50// This structure uniquely identifies a basic block section. 52// {Type: Default, Number: (unsigned)} (These are regular section IDs) 53// {Type: Exception, Number: 0} (ExceptionSectionID) 54// {Type: Cold, Number: 0} (ColdSectionID) 57Default = 0,
// Regular section (these sections are distinguished by the 59Exception,
// Special section type for exception handling blocks 60Cold,
// Special section type for cold blocks 66// Special unique sections for cold and exception blocks. 77// This is only used to construct the special cold and exception sections. 93 NumberInfo::getHashValue(SecID.
Number));
100// This structure represents the information for a basic block pertaining to 101// the basic block sections profile. 127 /// Pair of physical register and lane mask. 128 /// This is not simply a std::pair typedef because the members should be named 129 /// clearly as they both have an integer type. 149 /// The call frame size on entry to this basic block due to call frame setup 150 /// instructions in a predecessor. This is usually zero, unless basic blocks 151 /// are split in the middle of a call sequence. 153 /// This information is only maintained until PrologEpilogInserter eliminates 154 /// call frame pseudos. 155unsigned CallFrameSize = 0;
160 /// Keep track of the predecessor / successor basic blocks. 164 /// Keep track of the probabilities to the successors. This vector has the 165 /// same order as Successors, or it is empty if we don't use it (disable 167 std::vector<BranchProbability> Probs;
168usingprobability_iterator = std::vector<BranchProbability>::iterator;
169usingconst_probability_iterator =
170 std::vector<BranchProbability>::const_iterator;
172 std::optional<uint64_t> IrrLoopHeaderWeight;
174 /// Keep track of the physical registers that are livein of the basicblock. 175usingLiveInVector = std::vector<RegisterMaskPair>;
176 LiveInVector LiveIns;
178 /// Alignment of the basic block. One if the basic block does not need to be 181 /// Maximum amount of bytes that can be added to align the basic block. If the 182 /// alignment cannot be reached in this many bytes, no bytes are emitted. 183 /// Zero to represent no maximum. 184unsigned MaxBytesForAlignment = 0;
186 /// Indicate that this basic block is entered via an exception handler. 189 /// Indicate that this MachineBasicBlock is referenced somewhere other than 190 /// as predecessor/successor, a terminator MachineInstr, or a jump table. 191bool MachineBlockAddressTaken =
false;
193 /// If this MachineBasicBlock corresponds to an IR-level "blockaddress" 194 /// constant, this contains a pointer to that block. 197 /// Indicate that this basic block needs its symbol be emitted regardless of 198 /// whether the flow just falls-through to it. 199bool LabelMustBeEmitted =
false;
201 /// Indicate that this basic block is the entry block of an EH scope, i.e., 202 /// the block that used to have a catchpad or cleanuppad instruction in the 204bool IsEHScopeEntry =
false;
206 /// Indicates if this is a target block of a catchret. 207bool IsEHCatchretTarget =
false;
209 /// Indicate that this basic block is the entry block of an EH funclet. 210bool IsEHFuncletEntry =
false;
212 /// Indicate that this basic block is the entry block of a cleanup funclet. 213bool IsCleanupFuncletEntry =
false;
215 /// Fixed unique ID assigned to this basic block upon creation. Used with 216 /// basic block sections and basic block labels. 217 std::optional<UniqueBBID> BBID;
219 /// With basic block sections, this stores the Section ID of the basic block. 222// Indicate that this basic block begins a section. 223bool IsBeginSection =
false;
225// Indicate that this basic block ends a section. 226bool IsEndSection =
false;
228 /// Indicate that this basic block is the indirect dest of an INLINEASM_BR. 229bool IsInlineAsmBrIndirectTarget =
false;
231 /// since getSymbol is a relatively heavy-weight operation, the symbol 232 /// is only computed once and is cached. 233mutable MCSymbol *CachedMCSymbol =
nullptr;
235 /// Cached MCSymbol for this block (used if IsEHCatchRetTarget). 236mutable MCSymbol *CachedEHCatchretMCSymbol =
nullptr;
238 /// Marks the end of the basic block. Used during basic block sections to 239 /// calculate the size of the basic block, or the BB section ending with it. 240mutable MCSymbol *CachedEndMCSymbol =
nullptr;
242// Intrusive list support 243 MachineBasicBlock() =
default;
247 ~MachineBasicBlock();
249// MachineBasicBlocks are allocated and owned by MachineFunction. 253 /// Return the LLVM basic block that this instance corresponded to originally. 254 /// Note that this may be NULL if this instance does not correspond directly 255 /// to an LLVM basic block. 258 /// Remove the reference to the underlying IR BasicBlock. This is for 259 /// reduction tools and should generally not be used. 264 /// Check if there is a name of corresponding LLVM basic block. 267 /// Return the name of the corresponding LLVM basic block, or an empty string. 270 /// Return a formatted string to identify this block and its parent function. 273 /// Test whether this block is used as something other than the target 274 /// of a terminator, exception-handling target, or jump table. This is 275 /// either the result of an IR-level "blockaddress", or some form 276 /// of target-specific branch lowering. 278return MachineBlockAddressTaken || AddressTakenIRBlock;
281 /// Test whether this block is used as something other than the target of a 282 /// terminator, exception-handling target, jump table, or IR blockaddress. 283 /// For example, its address might be loaded into a register, or 284 /// stored in some branch table that isn't part of MachineJumpTableInfo. 287 /// Test whether this block is the target of an IR BlockAddress. (There can 288 /// more than one MBB associated with an IR BB where the address is taken.) 291 /// Retrieves the BasicBlock which corresponds to this MachineBasicBlock. 294 /// Set this block to indicate that its address is used as something other 295 /// than the target of a terminator, exception-handling target, jump table, 296 /// or IR-level "blockaddress". 299 /// Set this block to reflect that it corresponds to an IR-level basic block 300 /// with a BlockAddress. 303 /// Test whether this block must have its label emitted. 306 /// Set this block to reflect that, regardless how we flow to it, we need 307 /// its label be emitted. 310 /// Return the MachineFunction containing this basic block. 325unsignedsize()
const{
return (
unsigned)Insts.size(); }
327boolempty()
const{
return Insts.empty(); }
370 /// Support for MachineInstr::getNextNode(). 372return &MachineBasicBlock::Insts;
382 /// Returns a range that iterates over the phis in the basic block. 390// Machine-CFG iterators 410 {
return Predecessors.
rbegin();}
412{
return Predecessors.
rbegin();}
414 {
return Predecessors.
rend(); }
416{
return Predecessors.
rend(); }
418return (
unsigned)Predecessors.
size();
426 {
return Successors.
rbegin(); }
428{
return Successors.
rbegin(); }
430 {
return Successors.
rend(); }
432{
return Successors.
rend(); }
434return (
unsigned)Successors.
size();
451// LiveIn management methods. 453 /// Adds the specified register as a live in. Note that it is an error to add 454 /// the same register to the same set more than once unless the intention is 455 /// to call sortUniqueLiveIns after all registers are added. 461 LiveIns.push_back(RegMaskPair);
464 /// Sorts and uniques the LiveIns vector. It can be significantly faster to do 465 /// this than repeatedly calling isLiveIn before calling addLiveIn for every 466 /// LiveIn insertion. 469 /// Clear live in list. 472 /// Clear the live in list, and return the removed live in's in \p OldLiveIns. 473 /// Requires that the vector \p OldLiveIns is empty. 474voidclearLiveIns(std::vector<RegisterMaskPair> &OldLiveIns);
476 /// Add PhysReg as live in to this block, and ensure that there is a copy of 477 /// PhysReg to a virtual register of class RC. Return the virtual register 478 /// that is a copy of the live in PhysReg. 481 /// Remove the specified register from the live in set. 485 /// Return true if the specified register is in the live in set. 489// Iteration support for live in sets. These sets are kept in sorted 490// order by their register number. 493 /// Unlike livein_begin, this method does not check that the liveness 494 /// information is accurate. Still for debug purposes it may be useful 495 /// to have iterators that won't assert if the liveness information 509 /// Remove entry from the livein set and return iterator to the next. 512const std::vector<RegisterMaskPair> &
getLiveIns()
const{
return LiveIns; }
524 : ExceptionPointer(ExceptionPointer),
525 ExceptionSelector(ExceptionSelector), BlockI(
MBB.
succ_begin()),
529elseif (BlockI != BlockEnd) {
530 LiveRegI = (*BlockI)->livein_begin();
531if (!advanceToValidPosition())
533if (LiveRegI->PhysReg == ExceptionPointer ||
534 LiveRegI->PhysReg == ExceptionSelector)
542if (!advanceToValidPosition())
544 }
while ((*BlockI)->isEHPad() &&
545 (LiveRegI->PhysReg == ExceptionPointer ||
546 LiveRegI->PhysReg == ExceptionSelector));
565if (BlockI != BlockEnd)
566return BlockI ==
RHS.BlockI && LiveRegI ==
RHS.LiveRegI;
567returnRHS.BlockI == BlockEnd;
571return !(*
this ==
RHS);
574bool advanceToValidPosition() {
575if (LiveRegI != (*BlockI)->livein_end())
580 }
while (BlockI != BlockEnd && (*BlockI)->livein_empty());
581if (BlockI == BlockEnd)
584 LiveRegI = (*BlockI)->livein_begin();
588MCPhysReg ExceptionPointer, ExceptionSelector;
594 /// Iterator scanning successor basic blocks' liveins to determine the 595 /// registers potentially live at the end of this block. There may be 596 /// duplicates or overlapping registers in the list returned. 605 /// Get the clobber mask for the start of this basic block. Funclets use this 606 /// to prevent register allocation across funclet transitions. 609 /// Get the clobber mask for the end of the basic block. 610 /// \see getBeginClobberMask() 613 /// Return alignment of the basic block. 616 /// Set alignment of the basic block. 624 /// Return the maximum amount of padding allowed for aligning the basic block. 627 /// Set the maximum amount of padding allowed for aligning the basic block 629 MaxBytesForAlignment = MaxBytes;
632 /// Returns true if the block is a landing pad. That is this basic block is 633 /// entered via an exception handler. 636 /// Indicates the block is a landing pad. That is this basic block is entered 637 /// via an exception handler. 642 /// Returns true if this is the entry block of the function. 645 /// Returns true if this is the entry block of an EH scope, i.e., the block 646 /// that used to have a catchpad or cleanuppad instruction in the LLVM IR. 649 /// Indicates if this is the entry block of an EH scope, i.e., the block that 650 /// that used to have a catchpad or cleanuppad instruction in the LLVM IR. 653 /// Returns true if this is a target block of a catchret. 656 /// Indicates if this is a target block of a catchret. 659 /// Returns true if this is the entry block of an EH funclet. 662 /// Indicates if this is the entry block of an EH funclet. 665 /// Returns true if this is the entry block of a cleanup funclet. 668 /// Indicates if this is the entry block of a cleanup funclet. 671 /// Returns true if this block begins any section. 674 /// Returns true if this block ends any section. 681 std::optional<UniqueBBID>
getBBID()
const{
return BBID; }
683 /// Returns the section ID of this basic block. 686 /// Sets the fixed BBID of this basic block. 688assert(!BBID.has_value() &&
"Cannot change BBID.");
692 /// Sets the section ID for this basic block. 695 /// Returns the MCSymbol marking the end of this basic block. 698 /// Returns true if this block may have an INLINEASM_BR (overestimate, by 699 /// checking if any of the successors are indirect targets of any inlineasm_br 700 /// in the function). 703 /// Returns true if this is the indirect dest of an INLINEASM_BR. 705return IsInlineAsmBrIndirectTarget;
708 /// Indicates if this is the indirect dest of an INLINEASM_BR. 710 IsInlineAsmBrIndirectTarget = V;
713 /// Returns true if it is legal to hoist instructions into this block. 716// Code Layout methods. 718 /// Move 'this' block before or after the specified block. This only moves 719 /// the block, it does not modify the CFG or adjust potential fall-throughs at 720 /// the end of the block. 724 /// Returns true if this and MBB belong to the same section. 729 /// Update the terminator instructions in block to account for changes to 730 /// block layout which may have been made. PreviousLayoutSuccessor should be 731 /// set to the block which may have been used as fallthrough before the block 732 /// layout was modified. If the block previously fell through to that block, 733 /// it may now need a branch. If it previously branched to another block, it 734 /// may now be able to fallthrough to the current layout successor. 737// Machine-CFG mutators 739 /// Add Succ as a successor of this MachineBasicBlock. The Predecessors list 740 /// of Succ is automatically updated. PROB parameter is stored in 741 /// Probabilities list. The default probability is set as unknown. Mixing 742 /// known and unknown probabilities in successor list is not allowed. When all 743 /// successors have unknown probabilities, 1 / N is returned as the 744 /// probability for each successor, where N is the number of successors. 746 /// Note that duplicate Machine CFG edges are not allowed. 750 /// Add Succ as a successor of this MachineBasicBlock. The Predecessors list 751 /// of Succ is automatically updated. The probability is not provided because 752 /// BPI is not available (e.g. -O0 is used), in which case edge probabilities 753 /// won't be used. Using this interface can save some space. 756 /// Set successor probability of a given iterator. 759 /// Normalize probabilities of all successors so that the sum of them becomes 760 /// one. This is usually done when the current update on this MBB is done, and 761 /// the sum of its successors' probabilities is not guaranteed to be one. The 762 /// user is responsible for the correct use of this function. 763 /// MBB::removeSuccessor() has an option to do this automatically. 768 /// Validate successors' probabilities and check if the sum of them is 769 /// approximate one. This only works in DEBUG mode. 772 /// Remove successor from the successors list of this MachineBasicBlock. The 773 /// Predecessors list of Succ is automatically updated. 774 /// If NormalizeSuccProbs is true, then normalize successors' probabilities 775 /// after the successor is removed. 777bool NormalizeSuccProbs =
false);
779 /// Remove specified successor from the successors list of this 780 /// MachineBasicBlock. The Predecessors list of Succ is automatically updated. 781 /// If NormalizeSuccProbs is true, then normalize successors' probabilities 782 /// after the successor is removed. 783 /// Return the iterator to the element after the one removed. 785bool NormalizeSuccProbs =
false);
787 /// Replace successor OLD with NEW and update probability info. 790 /// Copy a successor (and any probability info) from original block to this 791 /// block's. Uses an iterator into the original blocks successors. 793 /// This is useful when doing a partial clone of successors. Afterward, the 794 /// probabilities may need to be normalized. 797 /// Split the old successor into old plus new and updates the probability 800bool NormalizeSuccProbs =
false);
802 /// Transfers all the successors from MBB to this machine basic block (i.e., 803 /// copies all the successors FromMBB and remove all the successors from 807 /// Transfers all the successors, as in transferSuccessors, and update PHI 808 /// operands in the successor blocks which refer to FromMBB to refer to this. 811 /// Return true if any of the successors have probabilities attached to them. 814 /// Return true if the specified MBB is a predecessor of this block. 817 /// Return true if the specified MBB is a successor of this block. 820 /// Return true if the specified MBB will be emitted immediately after this 821 /// block, such that if this block exits by falling through, control will 822 /// transfer to the specified MBB. Note that MBB need not be a successor at 823 /// all, for example if this block ends with an unconditional branch to some 827 /// Return the successor of this block if it has a single successor. 828 /// Otherwise return a null pointer. 836 /// Return the predecessor of this block if it has a single predecessor. 837 /// Otherwise return a null pointer. 845 /// Return the fallthrough block if the block can implicitly 846 /// transfer control to the block after it by falling off the end of 847 /// it. If an explicit branch to the fallthrough block is not allowed, 848 /// set JumpToFallThrough to be false. Non-null return is a conservative 852 /// Return the fallthrough block if the block can implicitly 853 /// transfer control to it's successor, whether by a branch or 854 /// a fallthrough. Non-null return is a conservative answer. 857 /// Return true if the block can implicitly transfer control to the 858 /// block after it by falling off the end of it. This should return 859 /// false if it can reach the block after it, but it uses an 860 /// explicit branch to do so (e.g., a table jump). True is a 861 /// conservative answer. 864 /// Returns a pointer to the first instruction in this block that is not a 865 /// PHINode instruction. When adding instructions to the beginning of the 866 /// basic block, they should be added before the returned value, not before 867 /// the first instruction, which might be PHI. 868 /// Returns end() is there's no non-PHI instruction. 874 /// Return the first instruction in MBB after I that is not a PHI or a label. 875 /// This is the correct point to insert lowered copies at the beginning of a 876 /// basic block that must be before any debugging information. 879 /// Return the first instruction in MBB after I that is not a PHI, label or 880 /// debug. This is the correct point to insert copies at the beginning of a 881 /// basic block. \p Reg is the register being used by a spill or defined for a 882 /// restore/split during register allocation. 884bool SkipPseudoOp =
true);
886 /// Returns an iterator to the first terminator instruction of this basic 887 /// block. If a terminator does not exist, it returns end(). 893 /// Same getFirstTerminator but it ignores bundles and return an 894 /// instr_iterator instead. 897 /// Finds the first terminator in a block by scanning forward. This can handle 898 /// cases in GlobalISel where there may be non-terminator instructions between 899 /// terminators, for which getFirstTerminator() will not work correctly. 902 /// Returns an iterator to the first non-debug instruction in the basic block, 903 /// or end(). Skip any pseudo probe operation if \c SkipPseudoOp is true. 904 /// Pseudo probes are like debug instructions which do not turn into real 905 /// machine code. We try to use the function to skip both debug instructions 906 /// and pseudo probe operations to avoid API proliferation. This should work 907 /// most of the time when considering optimizing the rest of code in the 908 /// block, except for certain cases where pseudo probes are designed to block 909 /// the optimizations. For example, code merge like optimizations are supposed 910 /// to be blocked by pseudo probes for better AutoFDO profile quality. 911 /// Therefore, they should be considered as a valid instruction when this 912 /// function is called in a context of such optimizations. On the other hand, 913 /// \c SkipPseudoOp should be true when it's used in optimizations that 914 /// unlikely hurt profile quality, e.g., without block merging. The default 915 /// value of \c SkipPseudoOp is set to true to maximize code quality in 916 /// general, with an explict false value passed in in a few places like branch 917 /// folding and if-conversion to favor profile quality. 924 /// Returns an iterator to the last non-debug instruction in the basic block, 925 /// or end(). Skip any pseudo operation if \c SkipPseudoOp is true. 926 /// Pseudo probes are like debug instructions which do not turn into real 927 /// machine code. We try to use the function to skip both debug instructions 928 /// and pseudo probe operations to avoid API proliferation. This should work 929 /// most of the time when considering optimizing the rest of code in the 930 /// block, except for certain cases where pseudo probes are designed to block 931 /// the optimizations. For example, code merge like optimizations are supposed 932 /// to be blocked by pseudo probes for better AutoFDO profile quality. 933 /// Therefore, they should be considered as a valid instruction when this 934 /// function is called in a context of such optimizations. On the other hand, 935 /// \c SkipPseudoOp should be true when it's used in optimizations that 936 /// unlikely hurt profile quality, e.g., without block merging. The default 937 /// value of \c SkipPseudoOp is set to true to maximize code quality in 938 /// general, with an explict false value passed in in a few places like branch 939 /// folding and if-conversion to favor profile quality. 946 /// Convenience function that returns true if the block ends in a return 952 /// Convenience function that returns true if the bock ends in a EH scope 953 /// return instruction. 958 /// Split a basic block into 2 pieces at \p SplitPoint. A new block will be 959 /// inserted after this block, and all instructions after \p SplitInst moved 960 /// to it (\p SplitInst will be in the original block). If \p LIS is provided, 961 /// LiveIntervals will be appropriately updated. \return the newly inserted 964 /// If \p UpdateLiveIns is true, this will ensure the live ins list is 965 /// accurate, including for physreg uses/defs in the original block. 969 /// Split the critical edge from this block to the given successor block, and 970 /// return the newly created block, or null if splitting is not possible. 972 /// This function updates LiveVariables, MachineDominatorTree, and 973 /// MachineLoopInfo, as applicable. 989// Helper method for new pass manager migration. 994 /// Check if the edge between this block and the given successor \p 995 /// Succ, can be split. If this returns true a subsequent call to 996 /// SplitCriticalEdge is guaranteed to return a valid basic block if 997 /// no changes occurred in the meantime. 1004 /// Insert MI into the instruction list before I, possibly inside a bundle. 1006 /// If the insertion point is inside a bundle, MI will be added to the bundle, 1007 /// otherwise MI will not be added to any bundle. That means this function 1008 /// alone can't be used to prepend or append instructions to bundles. See 1009 /// MIBundleBuilder::insert() for a more reliable way of doing that. 1012 /// Insert a range of instructions into the instruction list before I. 1013template<
typename IT>
1016"iterator points outside of basic block");
1017 Insts.insert(
I.getInstrIterator(), S,
E);
1020 /// Insert MI into the instruction list before I. 1023"iterator points outside of basic block");
1024assert(!
MI->isBundledWithPred() && !
MI->isBundledWithSucc() &&
1025"Cannot insert instruction with bundle flags");
1026return Insts.insert(
I.getInstrIterator(),
MI);
1029 /// Insert MI into the instruction list after I. 1032"iterator points outside of basic block");
1033assert(!
MI->isBundledWithPred() && !
MI->isBundledWithSucc() &&
1034"Cannot insert instruction with bundle flags");
1035return Insts.insertAfter(
I.getInstrIterator(),
MI);
1038 /// If I is bundled then insert MI into the instruction list after the end of 1039 /// the bundle, otherwise insert MI immediately after I. 1042"iterator points outside of basic block");
1043assert(!
MI->isBundledWithPred() && !
MI->isBundledWithSucc() &&
1044"Cannot insert instruction with bundle flags");
1045while (
I->isBundledWithSucc())
1047return Insts.insertAfter(
I,
MI);
1050 /// Remove an instruction from the instruction list and delete it. 1052 /// If the instruction is part of a bundle, the other instructions in the 1053 /// bundle will still be bundled after removing the single instruction. 1056 /// Remove an instruction from the instruction list and delete it. 1058 /// If the instruction is part of a bundle, the other instructions in the 1059 /// bundle will still be bundled after removing the single instruction. 1064 /// Remove a range of instructions from the instruction list and delete them. 1066return Insts.erase(
I.getInstrIterator(),
E.getInstrIterator());
1069 /// Remove an instruction or bundle from the instruction list and delete it. 1071 /// If I points to a bundle of instructions, they are all erased. 1076 /// Remove an instruction from the instruction list and delete it. 1078 /// If I is the head of a bundle of instructions, the whole bundle will be 1084 /// Remove the unbundled instruction from the instruction list without 1087 /// This function can not be used to remove bundled instructions, use 1088 /// remove_instr to remove individual instructions from a bundle. 1090assert(!
I->isBundled() &&
"Cannot remove bundled instructions");
1094 /// Remove the possibly bundled instruction from the instruction list 1095 /// without deleting it. 1097 /// If the instruction is part of a bundle, the other instructions in the 1098 /// bundle will still be bundled after removing the single instruction. 1105 /// Take an instruction from MBB 'Other' at the position From, and insert it 1106 /// into this MBB right before 'Where'. 1108 /// If From points to a bundle of instructions, the whole bundle is moved. 1110// The range splice() doesn't allow noop moves, but this one does. 1115 /// Take a block of instructions from MBB 'Other' in the range [From, To), 1116 /// and insert them into this MBB right before 'Where'. 1118 /// The instruction at 'Where' must not be included in the range of 1119 /// instructions to move. 1126 /// This method unlinks 'this' from the containing function, and returns it, 1127 /// but does not delete it. 1130 /// This method unlinks 'this' from the containing function and deletes it. 1133 /// Given a machine basic block that branched to 'Old', change the code and 1134 /// CFG so that it branches to 'New' instead. 1137 /// Update all phi nodes in this basic block to refer to basic block \p New 1138 /// instead of basic block \p Old. 1141 /// Find the next valid DebugLoc starting at MBBI, skipping any debug 1142 /// instructions. Return UnknownLoc if there is none. 1148 /// Has exact same behavior as @ref findDebugLoc (it also searches towards the 1149 /// end of this MBB) except that this function takes a reverse iterator to 1150 /// identify the starting MI. 1156 /// Find the previous valid DebugLoc preceding MBBI, skipping any debug 1157 /// instructions. It is possible to find the last DebugLoc in the MBB using 1158 /// findPrevDebugLoc(instr_end()). Return UnknownLoc if there is none. 1164 /// Has exact same behavior as @ref findPrevDebugLoc (it also searches towards 1165 /// the beginning of this MBB) except that this function takes reverse 1166 /// iterator to identify the starting MI. A minor difference compared to 1167 /// findPrevDebugLoc is that we can't start scanning at "instr_end". 1173 /// Find and return the merged DebugLoc of the branch instructions of the 1174 /// block. Return UnknownLoc if there is none. 1177 /// Possible outcome of a register liveness query to computeRegisterLiveness() 1179LQR_Live,
///< Register is known to be (at least partially) live. 1181LQR_Unknown///< Register liveness not decidable from local neighborhood. 1184 /// Return whether (physical) register \p Reg has been defined and not 1185 /// killed as of just before \p Before. 1187 /// Search is localised to a neighborhood of \p Neighborhood instructions 1188 /// before (searching for defs or kills) and \p Neighborhood instructions 1189 /// after (searching just for defs) \p Before. 1191 /// \p Reg must be a physical register. 1195unsigned Neighborhood = 10)
const;
1197// Debugging methods. 1200bool IsStandalone =
true)
const;
1202constSlotIndexes * =
nullptr,
bool IsStandalone =
true)
const;
1212// Printing method used by LoopInfo. 1215 /// MachineBasicBlocks are uniquely numbered at the function level, unless 1216 /// they're not in a MachineFunction yet, in which case this will return -1. 1220 /// Return the call frame size on entry to this basic block. 1222 /// Set the call frame size on entry to this basic block. 1225 /// Return the MCSymbol for this basic block. 1228 /// Return the EHCatchret Symbol for this basic block. 1232return IrrLoopHeaderWeight;
1236 IrrLoopHeaderWeight = Weight;
1239 /// Return probability of the edge from this block to MBB. This method should 1240 /// NOT be called directly, but by using getEdgeProbability method from 1241 /// MachineBranchProbabilityInfo class. 1245 /// Return probability iterator corresponding to the I successor iterator. 1247 const_probability_iterator
1253// Methods used to maintain doubly linked list of blocks... 1256// Machine-CFG mutators 1258 /// Add Pred as a predecessor of this MachineBasicBlock. Don't do this 1259 /// unless you know what you're doing, because it doesn't update Pred's 1260 /// successors list. Use Pred->addSuccessor instead. 1263 /// Remove Pred as a predecessor of this MachineBasicBlock. Don't do this 1264 /// unless you know what you're doing, because it doesn't update Pred's 1265 /// successors list. Use Pred->removeSuccessor instead. 1271/// Prints a machine basic block reference. 1274/// %bb.5 - a machine basic block with MBB.getNumber() == 5. 1276/// Usage: OS << printMBBReference(MBB) << '\n'; 1279// This is useful when building IndexedMaps keyed on basic block pointers. 1283returnMBB->getNumber();
1287//===--------------------------------------------------------------------===// 1288// GraphTraits specializations for machine basic block graphs (machine-CFGs) 1289//===--------------------------------------------------------------------===// 1291// Provide specializations of GraphTraits to be able to treat a 1292// MachineFunction as a graph of MachineBasicBlocks. 1309static_assert(GraphHasNodeNumbers<MachineBasicBlock *>,
1310"GraphTraits getNumber() not detected");
1326static_assert(GraphHasNodeNumbers<const MachineBasicBlock *>,
1327"GraphTraits getNumber() not detected");
1329// Provide specializations of GraphTraits to be able to treat a 1330// MachineFunction as a graph of MachineBasicBlocks and to walk it 1331// in inverse order. Inverse order for a function is considered 1332// to be when traversing the predecessor edges of a MBB 1333// instead of the successor edges. 1352static_assert(GraphHasNodeNumbers<Inverse<MachineBasicBlock *>>,
1353"GraphTraits getNumber() not detected");
1372static_assert(GraphHasNodeNumbers<Inverse<const MachineBasicBlock *>>,
1373"GraphTraits getNumber() not detected");
1375// These accessors are handy for sharing templated code between IR and MIR. 1387/// MachineInstrSpan provides an interface to get an iteration range 1388/// containing the instruction it was initialized with, along with all 1389/// those instructions inserted prior to or following that instruction 1390/// at some point after the MachineInstrSpan is constructed. 1403return B ==
MBB.end() ?
MBB.begin() : std::next(B);
1411/// Increment \p It until it points to a non-debug instruction or to \p End 1412/// and return the resulting iterator. This function should only be used 1413/// MachineBasicBlock::{iterator, const_iterator, instr_iterator, 1414/// const_instr_iterator} and the respective reverse iterators. 1415template <
typename IterT>
1417bool SkipPseudoOp =
true) {
1419 (It->isDebugInstr() || (SkipPseudoOp && It->isPseudoProbe())))
1424/// Decrement \p It until it points to a non-debug instruction or to \p Begin 1425/// and return the resulting iterator. This function should only be used 1426/// MachineBasicBlock::{iterator, const_iterator, instr_iterator, 1427/// const_instr_iterator} and the respective reverse iterators. 1428template <
class IterT>
1430bool SkipPseudoOp =
true) {
1431while (It != Begin &&
1432 (It->isDebugInstr() || (SkipPseudoOp && It->isPseudoProbe())))
1437/// Increment \p It, then continue incrementing it while it points to a debug 1438/// instruction. A replacement for std::next. 1439template <
typename IterT>
1444/// Decrement \p It, then continue decrementing it while it points to a debug 1445/// instruction. A replacement for std::prev. 1446template <
typename IterT>
1447inline IterT
prev_nodbg(IterT It, IterT Begin,
bool SkipPseudoOp =
true) {
1451/// Construct a range iterator which begins at \p It and moves forwards until 1452/// \p End is reached, skipping any debug instructions. 1453template <
typename IterT>
1455bool SkipPseudoOp =
true) {
1457return !
MI.isDebugInstr() && !(SkipPseudoOp &&
MI.isPseudoProbe());
1461}
// end namespace llvm 1463#endif// LLVM_CODEGEN_MACHINEBASICBLOCK_H aarch64 AArch64 CCMP Pass
MachineBasicBlock MachineBasicBlock::iterator MBBI
static cl::opt< ITMode > IT(cl::desc("IT block support"), cl::Hidden, cl::init(DefaultIT), cl::values(clEnumValN(DefaultIT, "arm-default-it", "Generate any type of IT block"), clEnumValN(RestrictedIT, "arm-restrict-it", "Disallow complex IT blocks")))
BlockVerifier::State From
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines DenseMapInfo traits for DenseMap.
This file defines the little GraphTraits<X> template class that should be specialized by classes that...
A common definition of LaneBitmask for use in TableGen and CodeGen.
unsigned const TargetRegisterInfo * TRI
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SparseBitVector class.
A container for analyses that lazily runs them and caches their results.
LLVM Basic Block Representation.
static BranchProbability getUnknown()
static void normalizeProbabilities(ProbabilityIter Begin, ProbabilityIter End)
Wrapper class representing physical registers. Should be passed by value.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
This class prints out the machine instructions using the MIR serialization format.
liveout_iterator(const MachineBasicBlock &MBB, MCPhysReg ExceptionPointer, MCPhysReg ExceptionSelector, bool End)
liveout_iterator & operator++()
std::ptrdiff_t difference_type
reference operator*() const
std::input_iterator_tag iterator_category
liveout_iterator operator++(int)
bool operator==(const liveout_iterator &RHS) const
pointer operator->() const
bool operator!=(const liveout_iterator &RHS) const
const MachineInstr & instr_front() const
bool isInlineAsmBrIndirectTarget() const
Returns true if this is the indirect dest of an INLINEASM_BR.
DebugLoc rfindPrevDebugLoc(reverse_instr_iterator MBBI)
Has exact same behavior as findPrevDebugLoc (it also searches towards the beginning of this MBB) exce...
Instructions::const_reverse_iterator const_reverse_instr_iterator
unsigned pred_size() const
void transferSuccessorsAndUpdatePHIs(MachineBasicBlock *FromMBB)
Transfers all the successors, as in transferSuccessors, and update PHI operands in the successor bloc...
bool hasEHPadSuccessor() const
void setBBID(const UniqueBBID &V)
Sets the fixed BBID of this basic block.
iterator erase(MachineInstr *I)
Remove an instruction from the instruction list and delete it.
void normalizeSuccProbs()
Normalize probabilities of all successors so that the sum of them becomes one.
void setAddressTakenIRBlock(BasicBlock *BB)
Set this block to reflect that it corresponds to an IR-level basic block with a BlockAddress.
livein_iterator livein_end() const
iterator getFirstTerminatorForward()
Finds the first terminator in a block by scanning forward.
bool isEHPad() const
Returns true if the block is a landing pad.
iterator_range< liveout_iterator > liveouts() const
const MachineInstr & back() const
void replacePhiUsesWith(MachineBasicBlock *Old, MachineBasicBlock *New)
Update all phi nodes in this basic block to refer to basic block New instead of basic block Old.
SmallVectorImpl< MachineBasicBlock * >::reverse_iterator pred_reverse_iterator
void setIsEHCatchretTarget(bool V=true)
Indicates if this is a target block of a catchret.
MachineInstr * remove_instr(MachineInstr *I)
Remove the possibly bundled instruction from the instruction list without deleting it.
instr_iterator instr_begin()
void setIsEndSection(bool V=true)
void setIrrLoopHeaderWeight(uint64_t Weight)
MachineBasicBlock * getLogicalFallThrough()
Return the fallthrough block if the block can implicitly transfer control to it's successor,...
MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
void setIsCleanupFuncletEntry(bool V=true)
Indicates if this is the entry block of a cleanup funclet.
SmallVectorImpl< MachineBasicBlock * >::const_iterator const_succ_iterator
DebugLoc rfindPrevDebugLoc(reverse_iterator MBBI)
MCSymbol * getEHCatchretSymbol() const
Return the EHCatchret Symbol for this basic block.
const_pred_iterator pred_end() const
void moveBefore(MachineBasicBlock *NewAfter)
Move 'this' block before or after the specified block.
void setLabelMustBeEmitted()
Set this block to reflect that, regardless how we flow to it, we need its label be emitted.
void replaceSuccessor(MachineBasicBlock *Old, MachineBasicBlock *New)
Replace successor OLD with NEW and update probability info.
const_pred_reverse_iterator pred_rend() const
MachineBasicBlock * getFallThrough(bool JumpToFallThrough=true)
Return the fallthrough block if the block can implicitly transfer control to the block after it by fa...
void transferSuccessors(MachineBasicBlock *FromMBB)
Transfers all the successors from MBB to this machine basic block (i.e., copies all the successors Fr...
MachineBasicBlock * SplitCriticalEdge(MachineBasicBlock *Succ, Pass &P, std::vector< SparseBitVector<> > *LiveInSets=nullptr, MachineDomTreeUpdater *MDTU=nullptr)
Split the critical edge from this block to the given successor block, and return the newly created bl...
bool hasLabelMustBeEmitted() const
Test whether this block must have its label emitted.
const_iterator getFirstNonDebugInstr(bool SkipPseudoOp=true) const
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
BranchProbability getSuccProbability(const_succ_iterator Succ) const
Return probability of the edge from this block to MBB.
const_reverse_instr_iterator instr_rend() const
iterator_range< livein_iterator > liveins() const
void setAlignment(Align A, unsigned MaxBytes)
iterator_range< iterator > phis()
Returns a range that iterates over the phis in the basic block.
reverse_instr_iterator instr_rbegin()
MachineInstrBundleIterator< const MachineInstr, true > const_reverse_iterator
SmallVectorImpl< MachineBasicBlock * >::reverse_iterator succ_reverse_iterator
instr_iterator erase_instr(MachineInstr *I)
Remove an instruction from the instruction list and delete it.
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
void push_back(MachineInstr *MI)
iterator SkipPHIsAndLabels(iterator I)
Return the first instruction in MBB after I that is not a PHI or a label.
pred_reverse_iterator pred_rbegin()
void addSuccessorWithoutProb(MachineBasicBlock *Succ)
Add Succ as a successor of this MachineBasicBlock.
bool hasName() const
Check if there is a name of corresponding LLVM basic block.
MachineBasicBlock * getSinglePredecessor()
void setCallFrameSize(unsigned N)
Set the call frame size on entry to this basic block.
std::optional< UniqueBBID > getBBID() const
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
void splitSuccessor(MachineBasicBlock *Old, MachineBasicBlock *New, bool NormalizeSuccProbs=false)
Split the old successor into old plus new and updates the probability info.
SmallVectorImpl< MachineBasicBlock * >::const_reverse_iterator const_succ_reverse_iterator
liveout_iterator liveout_end() const
const_instr_iterator instr_begin() const
const_succ_iterator succ_begin() const
const_succ_reverse_iterator succ_rbegin() const
pred_reverse_iterator pred_rend()
@ PrintNameIr
Add IR name where available.
@ PrintNameAttributes
Print attributes.
void updateTerminator(MachineBasicBlock *PreviousLayoutSuccessor)
Update the terminator instructions in block to account for changes to block layout which may have bee...
const MachineBasicBlock * getSinglePredecessor() const
Return the predecessor of this block if it has a single predecessor.
iterator SkipPHIsLabelsAndDebug(iterator I, Register Reg=Register(), bool SkipPseudoOp=true)
Return the first instruction in MBB after I that is not a PHI, label or debug.
bool canFallThrough()
Return true if the block can implicitly transfer control to the block after it by falling off the end...
void setSuccProbability(succ_iterator I, BranchProbability Prob)
Set successor probability of a given iterator.
iterator getFirstNonDebugInstr(bool SkipPseudoOp=true)
Returns an iterator to the first non-debug instruction in the basic block, or end().
succ_iterator succ_begin()
DebugLoc rfindDebugLoc(reverse_iterator MBBI)
bool livein_empty() const
void removeLiveIn(MCRegister Reg, LaneBitmask LaneMask=LaneBitmask::getAll())
Remove the specified register from the live in set.
iterator erase(iterator I, iterator E)
Remove a range of instructions from the instruction list and delete them.
const MachineInstr & front() const
void printAsOperand(raw_ostream &OS, bool PrintType=true) const
MachineInstr * remove(MachineInstr *I)
Remove the unbundled instruction from the instruction list without deleting it.
const_instr_range instrs() const
const_reverse_iterator rbegin() const
void clearBasicBlock()
Remove the reference to the underlying IR BasicBlock.
unsigned getMaxBytesForAlignment() const
Return the maximum amount of padding allowed for aligning the basic block.
void setMaxBytesForAlignment(unsigned MaxBytes)
Set the maximum amount of padding allowed for aligning the basic block.
void validateSuccProbs() const
Validate successors' probabilities and check if the sum of them is approximate one.
iterator_range< const_pred_iterator > predecessors() const
const MachineInstr & instr_back() const
bool isIRBlockAddressTaken() const
Test whether this block is the target of an IR BlockAddress.
LiveInVector::const_iterator livein_iterator
MCSymbol * getEndSymbol() const
Returns the MCSymbol marking the end of this basic block.
void splice(iterator Where, MachineBasicBlock *Other, iterator From, iterator To)
Take a block of instructions from MBB 'Other' in the range [From, To), and insert them into this MBB ...
void clearLiveIns()
Clear live in list.
bool isEHFuncletEntry() const
Returns true if this is the entry block of an EH funclet.
const_iterator getLastNonDebugInstr(bool SkipPseudoOp=true) const
LivenessQueryResult computeRegisterLiveness(const TargetRegisterInfo *TRI, MCRegister Reg, const_iterator Before, unsigned Neighborhood=10) const
Return whether (physical) register Reg has been defined and not killed as of just before Before.
iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
bool sameSection(const MachineBasicBlock *MBB) const
Returns true if this and MBB belong to the same section.
const std::vector< RegisterMaskPair > & getLiveIns() const
iterator insert(iterator I, MachineInstr *MI)
Insert MI into the instruction list before I.
livein_iterator livein_begin() const
unsigned succ_size() const
bool isReturnBlock() const
Convenience function that returns true if the block ends in a return instruction.
iterator_range< livein_iterator > liveins_dbg() const
const uint32_t * getBeginClobberMask(const TargetRegisterInfo *TRI) const
Get the clobber mask for the start of this basic block.
bool hasAddressTaken() const
Test whether this block is used as something other than the target of a terminator,...
MBBSectionID getSectionID() const
Returns the section ID of this basic block.
void setAlignment(Align A)
Set alignment of the basic block.
bool isEHScopeEntry() const
Returns true if this is the entry block of an EH scope, i.e., the block that used to have a catchpad ...
MachineInstr & instr_back()
bool isEntryBlock() const
Returns true if this is the entry block of the function.
iterator_range< const_instr_iterator > const_instr_range
void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
void copySuccessor(const MachineBasicBlock *Orig, succ_iterator I)
Copy a successor (and any probability info) from original block to this block's.
SmallVectorImpl< MachineBasicBlock * >::iterator succ_iterator
const_pred_reverse_iterator pred_rbegin() const
void addLiveIn(const RegisterMaskPair &RegMaskPair)
MachineBasicBlock * SplitCriticalEdge(MachineBasicBlock *Succ, MachineFunctionAnalysisManager &MFAM, std::vector< SparseBitVector<> > *LiveInSets=nullptr, MachineDomTreeUpdater *MDTU=nullptr)
MachineBasicBlock * getSingleSuccessor()
BasicBlock * getAddressTakenIRBlock() const
Retrieves the BasicBlock which corresponds to this MachineBasicBlock.
bool isEHCatchretTarget() const
Returns true if this is a target block of a catchret.
const_iterator getFirstNonPHI() const
void sortUniqueLiveIns()
Sorts and uniques the LiveIns vector.
const MachineBasicBlock * getSingleSuccessor() const
Return the successor of this block if it has a single successor.
iterator_range< const_iterator > phis() const
const_instr_iterator instr_end() const
liveout_iterator liveout_begin() const
Iterator scanning successor basic blocks' liveins to determine the registers potentially live at the ...
DebugLoc findDebugLoc(iterator MBBI)
SmallVectorImpl< MachineBasicBlock * >::iterator pred_iterator
void removeSuccessor(MachineBasicBlock *Succ, bool NormalizeSuccProbs=false)
Remove successor from the successors list of this MachineBasicBlock.
const_succ_iterator succ_end() const
iterator getFirstNonPHI()
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
const_iterator begin() const
bool isPredecessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB is a predecessor of this block.
bool hasSuccessorProbabilities() const
Return true if any of the successors have probabilities attached to them.
void setSectionID(MBBSectionID V)
Sets the section ID for this basic block.
iterator_range< const_iterator > terminators() const
livein_iterator livein_begin_dbg() const
Unlike livein_begin, this method does not check that the liveness information is accurate.
DebugLoc rfindDebugLoc(reverse_instr_iterator MBBI)
Has exact same behavior as findDebugLoc (it also searches towards the end of this MBB) except that th...
const_pred_iterator pred_begin() const
void print(raw_ostream &OS, const SlotIndexes *=nullptr, bool IsStandalone=true) const
reverse_instr_iterator instr_rend()
const_reverse_iterator rend() const
DebugLoc findDebugLoc(instr_iterator MBBI)
Find the next valid DebugLoc starting at MBBI, skipping any debug instructions.
Instructions::iterator instr_iterator
pred_iterator pred_begin()
iterator getLastNonDebugInstr(bool SkipPseudoOp=true)
Returns an iterator to the last non-debug instruction in the basic block, or end().
void ReplaceUsesOfBlockWith(MachineBasicBlock *Old, MachineBasicBlock *New)
Given a machine basic block that branched to 'Old', change the code and CFG so that it branches to 'N...
MachineInstrBundleIterator< MachineInstr, true > reverse_iterator
succ_reverse_iterator succ_rbegin()
bool isLayoutSuccessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB will be emitted immediately after this block, such that if this bloc...
static Instructions MachineBasicBlock::* getSublistAccess(MachineInstr *)
Support for MachineInstr::getNextNode().
DebugLoc findPrevDebugLoc(instr_iterator MBBI)
Find the previous valid DebugLoc preceding MBBI, skipping any debug instructions.
MachineBasicBlock * splitAt(MachineInstr &SplitInst, bool UpdateLiveIns=true, LiveIntervals *LIS=nullptr)
Split a basic block into 2 pieces at SplitPoint.
MachineFunction * getParent()
void eraseFromParent()
This method unlinks 'this' from the containing function and deletes it.
friend class MachineFunction
void setIsInlineAsmBrIndirectTarget(bool V=true)
Indicates if this is the indirect dest of an INLINEASM_BR.
instr_iterator instr_end()
Instructions::const_iterator const_instr_iterator
iterator_range< const_succ_iterator > successors() const
void addLiveIn(MCRegister PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
const_iterator getFirstTerminator() const
const_succ_reverse_iterator succ_rend() const
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
std::string getFullName() const
Return a formatted string to identify this block and its parent function.
bool isBeginSection() const
Returns true if this block begins any section.
DebugLoc findPrevDebugLoc(iterator MBBI)
iterator_range< iterator > terminators()
unsigned getCallFrameSize() const
Return the call frame size on entry to this basic block.
void setIsEHFuncletEntry(bool V=true)
Indicates if this is the entry block of an EH funclet.
DebugLoc findBranchDebugLoc()
Find and return the merged DebugLoc of the branch instructions of the block.
iterator_range< succ_iterator > successors()
instr_iterator getFirstInstrTerminator()
Same getFirstTerminator but it ignores bundles and return an instr_iterator instead.
reverse_iterator rbegin()
bool isMachineBlockAddressTaken() const
Test whether this block is used as something other than the target of a terminator,...
void printName(raw_ostream &os, unsigned printNameFlags=PrintNameIr, ModuleSlotTracker *moduleSlotTracker=nullptr) const
Print the basic block's name as:
iterator insertAfter(iterator I, MachineInstr *MI)
Insert MI into the instruction list after I.
bool isSuccessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB is a successor of this block.
iterator_range< pred_iterator > predecessors()
void splice(iterator Where, MachineBasicBlock *Other, iterator From)
Take an instruction from MBB 'Other' at the position From, and insert it into this MBB right before '...
bool isEHScopeReturnBlock() const
Convenience function that returns true if the bock ends in a EH scope return instruction.
bool isEndSection() const
Returns true if this block ends any section.
Align getAlignment() const
Return alignment of the basic block.
bool canSplitCriticalEdge(const MachineBasicBlock *Succ) const
Check if the edge between this block and the given successor Succ, can be split.
MachineInstrBundleIterator< MachineInstr > iterator
bool isLegalToHoistInto() const
Returns true if it is legal to hoist instructions into this block.
MachineInstr & instr_front()
SmallVectorImpl< MachineBasicBlock * >::const_iterator const_pred_iterator
const_reverse_instr_iterator instr_rbegin() const
iterator erase(iterator I)
Remove an instruction or bundle from the instruction list and delete it.
instr_iterator insertAfterBundle(instr_iterator I, MachineInstr *MI)
If I is bundled then insert MI into the instruction list after the end of the bundle,...
const_iterator end() const
StringRef getName() const
Return the name of the corresponding LLVM basic block, or an empty string.
SmallVectorImpl< MachineBasicBlock * >::const_reverse_iterator const_pred_reverse_iterator
bool mayHaveInlineAsmBr() const
Returns true if this block may have an INLINEASM_BR (overestimate, by checking if any of the successo...
LivenessQueryResult
Possible outcome of a register liveness query to computeRegisterLiveness()
@ LQR_Dead
Register is known to be fully dead.
@ LQR_Live
Register is known to be (at least partially) live.
@ LQR_Unknown
Register liveness not decidable from local neighborhood.
void setIsEHScopeEntry(bool V=true)
Indicates if this is the entry block of an EH scope, i.e., the block that that used to have a catchpa...
void moveAfter(MachineBasicBlock *NewBefore)
succ_reverse_iterator succ_rend()
void setMachineBlockAddressTaken()
Set this block to indicate that its address is used as something other than the target of a terminato...
std::optional< uint64_t > getIrrLoopHeaderWeight() const
const uint32_t * getEndClobberMask(const TargetRegisterInfo *TRI) const
Get the clobber mask for the end of the basic block.
void setIsBeginSection(bool V=true)
bool sizeWithoutDebugLargerThan(unsigned Limit) const
iterator_range< instr_iterator > instr_range
bool isLiveIn(MCRegister Reg, LaneBitmask LaneMask=LaneBitmask::getAll()) const
Return true if the specified register is in the live in set.
MachineBasicBlock * removeFromParent()
This method unlinks 'this' from the containing function, and returns it, but does not delete it.
void insert(iterator I, IT S, IT E)
Insert a range of instructions into the instruction list before I.
void setIsEHPad(bool V=true)
Indicates the block is a landing pad.
Instructions::reverse_iterator reverse_instr_iterator
bool isCleanupFuncletEntry() const
Returns true if this is the entry block of a cleanup funclet.
instr_iterator getInstrIterator() const
static MachineInstrBundleIterator getAtBundleBegin(instr_iterator MI)
Get the bundle iterator for the given instruction's bundle.
MachineInstrSpan provides an interface to get an iteration range containing the instruction it was in...
MachineBasicBlock::iterator getInitial()
MachineInstrSpan(MachineBasicBlock::iterator I, MachineBasicBlock *BB)
MachineBasicBlock::iterator begin()
MachineBasicBlock::iterator end()
Representation of each machine instruction.
bool isReturn(QueryType Type=AnyInBundle) const
bool isEHScopeReturn(QueryType Type=AnyInBundle) const
Return true if this is an instruction that marks the end of an EH scope, i.e., a catchpad or a cleanu...
Manage lifetime of a slot tracker for printing IR.
Pass interface - Implemented by all 'passes'.
Simple wrapper around std::function<void(raw_ostream&)>.
Wrapper class representing virtual and physical registers.
typename SuperClass::const_iterator const_iterator
typename SuperClass::iterator iterator
reverse_iterator rbegin()
std::reverse_iterator< const_iterator > const_reverse_iterator
std::reverse_iterator< iterator > reverse_iterator
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
The instances of the Type class are immutable: once they are created, they are never changed.
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
An intrusive list with ownership and callbacks specified/controlled by ilist_traits,...
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
A simple intrusive list implementation.
This file defines classes to implement an intrusive doubly linked list class (i.e.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
@ BasicBlock
Various leaf nodes.
unsigned combineHashValue(unsigned a, unsigned b)
Simplistic combination of 32-bit hash values into 32-bit hash values.
This is an optimization pass for GlobalISel generic memory operations.
IterT next_nodbg(IterT It, IterT End, bool SkipPseudoOp=true)
Increment It, then continue incrementing it while it points to a debug instruction.
auto pred_end(const MachineBasicBlock *BB)
auto successors(const MachineBasicBlock *BB)
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
auto pred_size(const MachineBasicBlock *BB)
IterT skipDebugInstructionsForward(IterT It, IterT End, bool SkipPseudoOp=true)
Increment It until it points to a non-debug instruction or to End and return the resulting iterator.
auto succ_size(const MachineBasicBlock *BB)
iterator_range< filter_iterator< detail::IterOfRange< RangeT >, PredicateT > > make_filter_range(RangeT &&Range, PredicateT Pred)
Convenience function that takes a range of elements and a predicate, and return a new filter_iterator...
auto instructionsWithoutDebug(IterT It, IterT End, bool SkipPseudoOp=true)
Construct a range iterator which begins at It and moves forwards until End is reached,...
IterT skipDebugInstructionsBackward(IterT It, IterT Begin, bool SkipPseudoOp=true)
Decrement It until it points to a non-debug instruction or to Begin and return the resulting iterator...
RNSuccIterator< NodeRef, BlockT, RegionT > succ_begin(NodeRef Node)
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
RNSuccIterator< NodeRef, BlockT, RegionT > succ_end(NodeRef Node)
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
auto pred_begin(const MachineBasicBlock *BB)
auto predecessors(const MachineBasicBlock *BB)
IterT prev_nodbg(IterT It, IterT Begin, bool SkipPseudoOp=true)
Decrement It, then continue decrementing it while it points to a debug instruction.
Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
Implement std::hash so that hash_code can be used in STL containers.
This struct is a compact representation of a valid (non-zero power of two) alignment.
static MBBSectionID getEmptyKey()
static unsigned getHashValue(const MBBSectionID &SecID)
static bool isEqual(const MBBSectionID &LHS, const MBBSectionID &RHS)
static MBBSectionID getTombstoneKey()
An information struct used to provide DenseMap with the various necessary components for a given valu...
static ChildIteratorType child_end(NodeRef N)
static NodeRef getEntryNode(Inverse< MachineBasicBlock * > G)
MachineBasicBlock::pred_iterator ChildIteratorType
static unsigned getNumber(MachineBasicBlock *BB)
static ChildIteratorType child_begin(NodeRef N)
static ChildIteratorType child_end(NodeRef N)
static unsigned getNumber(const MachineBasicBlock *BB)
static NodeRef getEntryNode(Inverse< const MachineBasicBlock * > G)
static ChildIteratorType child_begin(NodeRef N)
MachineBasicBlock::const_pred_iterator ChildIteratorType
static unsigned getNumber(MachineBasicBlock *BB)
MachineBasicBlock::succ_iterator ChildIteratorType
static NodeRef getEntryNode(MachineBasicBlock *BB)
static ChildIteratorType child_end(NodeRef N)
static ChildIteratorType child_begin(NodeRef N)
MachineBasicBlock::const_succ_iterator ChildIteratorType
static ChildIteratorType child_begin(NodeRef N)
static unsigned getNumber(const MachineBasicBlock *BB)
static NodeRef getEntryNode(const MachineBasicBlock *BB)
static ChildIteratorType child_end(NodeRef N)
static constexpr LaneBitmask getAll()
unsigned operator()(const MachineBasicBlock *MBB) const
bool operator!=(const MBBSectionID &Other) const
static const MBBSectionID ExceptionSectionID
static const MBBSectionID ColdSectionID
enum llvm::MBBSectionID::SectionType Type
bool operator==(const MBBSectionID &Other) const
Pair of physical register and lane mask.
RegisterMaskPair(MCPhysReg PhysReg, LaneBitmask LaneMask)
bool operator==(const RegisterMaskPair &other) const
Callbacks do nothing by default in iplist and ilist.
void transferNodesFromList(ilist_traits &FromList, instr_iterator First, instr_iterator Last)
void addNodeToList(MachineInstr *N)
void removeNodeFromList(MachineInstr *N)
void deleteNode(MachineInstr *MI)
Template traits for intrusive list.