LLVM 19.0.0git
MachineBasicBlock.h
Go to the documentation of this file.
1//===- llvm/CodeGen/MachineBasicBlock.h -------------------------*- C++ -*-===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8//
9// Collect the sequence of machine instructions for a basic block.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CODEGEN_MACHINEBASICBLOCK_H
14#define LLVM_CODEGEN_MACHINEBASICBLOCK_H
15
18#include "llvm/ADT/ilist.h"
22#include "llvm/IR/DebugLoc.h"
23#include "llvm/MC/LaneBitmask.h"
25#include <cassert>
26#include <cstdint>
27#include <iterator>
28#include <string>
29#include <vector>
30
31namespace llvm {
32
33class BasicBlock;
34class MachineFunction;
35class MCSymbol;
36class ModuleSlotTracker;
37class Pass;
38class Printable;
39class SlotIndexes;
40class StringRef;
41class raw_ostream;
42class LiveIntervals;
43class TargetRegisterClass;
44class TargetRegisterInfo;
45
46// This structure uniquely identifies a basic block section.
47// Possible values are
48// {Type: Default, Number: (unsigned)} (These are regular section IDs)
49// {Type: Exception, Number: 0} (ExceptionSectionID)
50// {Type: Cold, Number: 0} (ColdSectionID)
53 Default = 0, // Regular section (these sections are distinguished by the
54 // Number field).
55 Exception, // Special section type for exception handling blocks
56 Cold, // Special section type for cold blocks
58 unsigned Number;
59
60 MBBSectionID(unsigned N) : Type(Default), Number(N) {}
61
62 // Special unique sections for cold and exception blocks.
65
66 bool operator==(const MBBSectionID &Other) const {
67 return Type == Other.Type && Number == Other.Number;
68 }
69
70 bool operator!=(const MBBSectionID &Other) const { return !(*this == Other); }
71
72private:
73 // This is only used to construct the special cold and exception sections.
75};
76
77// This structure represents the information for a basic block pertaining to
78// the basic block sections profile.
79struct UniqueBBID {
80 unsigned BaseID;
81 unsigned CloneID;
82};
83
84template <> struct ilist_traits<MachineInstr> {
85private:
86 friend class MachineBasicBlock; // Set by the owning MachineBasicBlock.
87
88 MachineBasicBlock *Parent;
89
90 using instr_iterator =
92
93public:
96 void transferNodesFromList(ilist_traits &FromList, instr_iterator First,
97 instr_iterator Last);
99};
100
102 : public ilist_node_with_parent<MachineBasicBlock, MachineFunction> {
103public:
104 /// Pair of physical register and lane mask.
105 /// This is not simply a std::pair typedef because the members should be named
106 /// clearly as they both have an integer type.
108 public:
111
114
115 bool operator==(const RegisterMaskPair &other) const {
116 return PhysReg == other.PhysReg && LaneMask == other.LaneMask;
117 }
118 };
119
120private:
122
123 const BasicBlock *BB;
124 int Number;
125
126 /// The call frame size on entry to this basic block due to call frame setup
127 /// instructions in a predecessor. This is usually zero, unless basic blocks
128 /// are split in the middle of a call sequence.
129 ///
130 /// This information is only maintained until PrologEpilogInserter eliminates
131 /// call frame pseudos.
132 unsigned CallFrameSize = 0;
133
134 MachineFunction *xParent;
135 Instructions Insts;
136
137 /// Keep track of the predecessor / successor basic blocks.
138 std::vector<MachineBasicBlock *> Predecessors;
139 std::vector<MachineBasicBlock *> Successors;
140
141 /// Keep track of the probabilities to the successors. This vector has the
142 /// same order as Successors, or it is empty if we don't use it (disable
143 /// optimization).
144 std::vector<BranchProbability> Probs;
145 using probability_iterator = std::vector<BranchProbability>::iterator;
146 using const_probability_iterator =
147 std::vector<BranchProbability>::const_iterator;
148
149 std::optional<uint64_t> IrrLoopHeaderWeight;
150
151 /// Keep track of the physical registers that are livein of the basicblock.
152 using LiveInVector = std::vector<RegisterMaskPair>;
153 LiveInVector LiveIns;
154
155 /// Alignment of the basic block. One if the basic block does not need to be
156 /// aligned.
157 Align Alignment;
158 /// Maximum amount of bytes that can be added to align the basic block. If the
159 /// alignment cannot be reached in this many bytes, no bytes are emitted.
160 /// Zero to represent no maximum.
161 unsigned MaxBytesForAlignment = 0;
162
163 /// Indicate that this basic block is entered via an exception handler.
164 bool IsEHPad = false;
165
166 /// Indicate that this MachineBasicBlock is referenced somewhere other than
167 /// as predecessor/successor, a terminator MachineInstr, or a jump table.
168 bool MachineBlockAddressTaken = false;
169
170 /// If this MachineBasicBlock corresponds to an IR-level "blockaddress"
171 /// constant, this contains a pointer to that block.
172 BasicBlock *AddressTakenIRBlock = nullptr;
173
174 /// Indicate that this basic block needs its symbol be emitted regardless of
175 /// whether the flow just falls-through to it.
176 bool LabelMustBeEmitted = false;
177
178 /// Indicate that this basic block is the entry block of an EH scope, i.e.,
179 /// the block that used to have a catchpad or cleanuppad instruction in the
180 /// LLVM IR.
181 bool IsEHScopeEntry = false;
182
183 /// Indicates if this is a target block of a catchret.
184 bool IsEHCatchretTarget = false;
185
186 /// Indicate that this basic block is the entry block of an EH funclet.
187 bool IsEHFuncletEntry = false;
188
189 /// Indicate that this basic block is the entry block of a cleanup funclet.
190 bool IsCleanupFuncletEntry = false;
191
192 /// Fixed unique ID assigned to this basic block upon creation. Used with
193 /// basic block sections and basic block labels.
194 std::optional<UniqueBBID> BBID;
195
196 /// With basic block sections, this stores the Section ID of the basic block.
197 MBBSectionID SectionID{0};
198
199 // Indicate that this basic block begins a section.
200 bool IsBeginSection = false;
201
202 // Indicate that this basic block ends a section.
203 bool IsEndSection = false;
204
205 /// Indicate that this basic block is the indirect dest of an INLINEASM_BR.
206 bool IsInlineAsmBrIndirectTarget = false;
207
208 /// since getSymbol is a relatively heavy-weight operation, the symbol
209 /// is only computed once and is cached.
210 mutable MCSymbol *CachedMCSymbol = nullptr;
211
212 /// Cached MCSymbol for this block (used if IsEHCatchRetTarget).
213 mutable MCSymbol *CachedEHCatchretMCSymbol = nullptr;
214
215 /// Marks the end of the basic block. Used during basic block sections to
216 /// calculate the size of the basic block, or the BB section ending with it.
217 mutable MCSymbol *CachedEndMCSymbol = nullptr;
218
219 // Intrusive list support
220 MachineBasicBlock() = default;
221
222 explicit MachineBasicBlock(MachineFunction &MF, const BasicBlock *BB);
223
224 ~MachineBasicBlock();
225
226 // MachineBasicBlocks are allocated and owned by MachineFunction.
227 friend class MachineFunction;
228
229public:
230 /// Return the LLVM basic block that this instance corresponded to originally.
231 /// Note that this may be NULL if this instance does not correspond directly
232 /// to an LLVM basic block.
233 const BasicBlock *getBasicBlock() const { return BB; }
234
235 /// Remove the reference to the underlying IR BasicBlock. This is for
236 /// reduction tools and should generally not be used.
238 BB = nullptr;
239 }
240
241 /// Check if there is a name of corresponding LLVM basic block.
242 bool hasName() const;
243
244 /// Return the name of the corresponding LLVM basic block, or an empty string.
245 StringRef getName() const;
246
247 /// Return a formatted string to identify this block and its parent function.
248 std::string getFullName() const;
249
250 /// Test whether this block is used as something other than the target
251 /// of a terminator, exception-handling target, or jump table. This is
252 /// either the result of an IR-level "blockaddress", or some form
253 /// of target-specific branch lowering.
254 bool hasAddressTaken() const {
255 return MachineBlockAddressTaken || AddressTakenIRBlock;
256 }
257
258 /// Test whether this block is used as something other than the target of a
259 /// terminator, exception-handling target, jump table, or IR blockaddress.
260 /// For example, its address might be loaded into a register, or
261 /// stored in some branch table that isn't part of MachineJumpTableInfo.
262 bool isMachineBlockAddressTaken() const { return MachineBlockAddressTaken; }
263
264 /// Test whether this block is the target of an IR BlockAddress. (There can
265 /// more than one MBB associated with an IR BB where the address is taken.)
266 bool isIRBlockAddressTaken() const { return AddressTakenIRBlock; }
267
268 /// Retrieves the BasicBlock which corresponds to this MachineBasicBlock.
269 BasicBlock *getAddressTakenIRBlock() const { return AddressTakenIRBlock; }
270
271 /// Set this block to indicate that its address is used as something other
272 /// than the target of a terminator, exception-handling target, jump table,
273 /// or IR-level "blockaddress".
274 void setMachineBlockAddressTaken() { MachineBlockAddressTaken = true; }
275
276 /// Set this block to reflect that it corresponds to an IR-level basic block
277 /// with a BlockAddress.
278 void setAddressTakenIRBlock(BasicBlock *BB) { AddressTakenIRBlock = BB; }
279
280 /// Test whether this block must have its label emitted.
281 bool hasLabelMustBeEmitted() const { return LabelMustBeEmitted; }
282
283 /// Set this block to reflect that, regardless how we flow to it, we need
284 /// its label be emitted.
285 void setLabelMustBeEmitted() { LabelMustBeEmitted = true; }
286
287 /// Return the MachineFunction containing this basic block.
288 const MachineFunction *getParent() const { return xParent; }
289 MachineFunction *getParent() { return xParent; }
290
295
301
302 unsigned size() const { return (unsigned)Insts.size(); }
303 bool sizeWithoutDebugLargerThan(unsigned Limit) const;
304 bool empty() const { return Insts.empty(); }
305
306 MachineInstr &instr_front() { return Insts.front(); }
307 MachineInstr &instr_back() { return Insts.back(); }
308 const MachineInstr &instr_front() const { return Insts.front(); }
309 const MachineInstr &instr_back() const { return Insts.back(); }
310
311 MachineInstr &front() { return Insts.front(); }
312 MachineInstr &back() { return *--end(); }
313 const MachineInstr &front() const { return Insts.front(); }
314 const MachineInstr &back() const { return *--end(); }
315
316 instr_iterator instr_begin() { return Insts.begin(); }
317 const_instr_iterator instr_begin() const { return Insts.begin(); }
318 instr_iterator instr_end() { return Insts.end(); }
319 const_instr_iterator instr_end() const { return Insts.end(); }
320 reverse_instr_iterator instr_rbegin() { return Insts.rbegin(); }
321 const_reverse_instr_iterator instr_rbegin() const { return Insts.rbegin(); }
322 reverse_instr_iterator instr_rend () { return Insts.rend(); }
323 const_reverse_instr_iterator instr_rend () const { return Insts.rend(); }
324
330 }
331
332 iterator begin() { return instr_begin(); }
333 const_iterator begin() const { return instr_begin(); }
334 iterator end () { return instr_end(); }
335 const_iterator end () const { return instr_end(); }
338 }
341 }
345 }
346
347 /// Support for MachineInstr::getNextNode().
349 return &MachineBasicBlock::Insts;
350 }
351
353 return make_range(getFirstTerminator(), end());
354 }
356 return make_range(getFirstTerminator(), end());
357 }
358
359 /// Returns a range that iterates over the phis in the basic block.
361 return make_range(begin(), getFirstNonPHI());
362 }
364 return const_cast<MachineBasicBlock *>(this)->phis();
365 }
366
367 // Machine-CFG iterators
368 using pred_iterator = std::vector<MachineBasicBlock *>::iterator;
369 using const_pred_iterator = std::vector<MachineBasicBlock *>::const_iterator;
370 using succ_iterator = std::vector<MachineBasicBlock *>::iterator;
371 using const_succ_iterator = std::vector<MachineBasicBlock *>::const_iterator;
373 std::vector<MachineBasicBlock *>::reverse_iterator;
375 std::vector<MachineBasicBlock *>::const_reverse_iterator;
377 std::vector<MachineBasicBlock *>::reverse_iterator;
379 std::vector<MachineBasicBlock *>::const_reverse_iterator;
380 pred_iterator pred_begin() { return Predecessors.begin(); }
381 const_pred_iterator pred_begin() const { return Predecessors.begin(); }
382 pred_iterator pred_end() { return Predecessors.end(); }
383 const_pred_iterator pred_end() const { return Predecessors.end(); }
385 { return Predecessors.rbegin();}
387 { return Predecessors.rbegin();}
389 { return Predecessors.rend(); }
391 { return Predecessors.rend(); }
392 unsigned pred_size() const {
393 return (unsigned)Predecessors.size();
394 }
395 bool pred_empty() const { return Predecessors.empty(); }
396 succ_iterator succ_begin() { return Successors.begin(); }
397 const_succ_iterator succ_begin() const { return Successors.begin(); }
398 succ_iterator succ_end() { return Successors.end(); }
399 const_succ_iterator succ_end() const { return Successors.end(); }
401 { return Successors.rbegin(); }
403 { return Successors.rbegin(); }
405 { return Successors.rend(); }
407 { return Successors.rend(); }
408 unsigned succ_size() const {
409 return (unsigned)Successors.size();
410 }
411 bool succ_empty() const { return Successors.empty(); }
412
414 return make_range(pred_begin(), pred_end());
415 }
417 return make_range(pred_begin(), pred_end());
418 }
420 return make_range(succ_begin(), succ_end());
421 }
423 return make_range(succ_begin(), succ_end());
424 }
425
426 // LiveIn management methods.
427
428 /// Adds the specified register as a live in. Note that it is an error to add
429 /// the same register to the same set more than once unless the intention is
430 /// to call sortUniqueLiveIns after all registers are added.
431 void addLiveIn(MCRegister PhysReg,
432 LaneBitmask LaneMask = LaneBitmask::getAll()) {
433 LiveIns.push_back(RegisterMaskPair(PhysReg, LaneMask));
434 }
435 void addLiveIn(const RegisterMaskPair &RegMaskPair) {
436 LiveIns.push_back(RegMaskPair);
437 }
438
439 /// Sorts and uniques the LiveIns vector. It can be significantly faster to do
440 /// this than repeatedly calling isLiveIn before calling addLiveIn for every
441 /// LiveIn insertion.
442 void sortUniqueLiveIns();
443
444 /// Clear live in list.
445 void clearLiveIns();
446
447 /// Clear the live in list, and return the removed live in's in \p OldLiveIns.
448 /// Requires that the vector \p OldLiveIns is empty.
449 void clearLiveIns(std::vector<RegisterMaskPair> &OldLiveIns);
450
451 /// Add PhysReg as live in to this block, and ensure that there is a copy of
452 /// PhysReg to a virtual register of class RC. Return the virtual register
453 /// that is a copy of the live in PhysReg.
455
456 /// Remove the specified register from the live in set.
458 LaneBitmask LaneMask = LaneBitmask::getAll());
459
460 /// Return true if the specified register is in the live in set.
462 LaneBitmask LaneMask = LaneBitmask::getAll()) const;
463
464 // Iteration support for live in sets. These sets are kept in sorted
465 // order by their register number.
466 using livein_iterator = LiveInVector::const_iterator;
467
468 /// Unlike livein_begin, this method does not check that the liveness
469 /// information is accurate. Still for debug purposes it may be useful
470 /// to have iterators that won't assert if the liveness information
471 /// is not current.
472 livein_iterator livein_begin_dbg() const { return LiveIns.begin(); }
475 }
476
478 livein_iterator livein_end() const { return LiveIns.end(); }
479 bool livein_empty() const { return LiveIns.empty(); }
482 }
483
484 /// Remove entry from the livein set and return iterator to the next.
486
487 const std::vector<RegisterMaskPair> &getLiveIns() const { return LiveIns; }
488
490 public:
491 using iterator_category = std::input_iterator_tag;
492 using difference_type = std::ptrdiff_t;
494 using pointer = const RegisterMaskPair *;
496
498 MCPhysReg ExceptionSelector, bool End)
499 : ExceptionPointer(ExceptionPointer),
500 ExceptionSelector(ExceptionSelector), BlockI(MBB.succ_begin()),
501 BlockEnd(MBB.succ_end()) {
502 if (End)
503 BlockI = BlockEnd;
504 else if (BlockI != BlockEnd) {
505 LiveRegI = (*BlockI)->livein_begin();
506 if (!advanceToValidPosition())
507 return;
508 if (LiveRegI->PhysReg == ExceptionPointer ||
509 LiveRegI->PhysReg == ExceptionSelector)
510 ++(*this);
511 }
512 }
513
515 do {
516 ++LiveRegI;
517 if (!advanceToValidPosition())
518 return *this;
519 } while ((*BlockI)->isEHPad() &&
520 (LiveRegI->PhysReg == ExceptionPointer ||
521 LiveRegI->PhysReg == ExceptionSelector));
522 return *this;
523 }
524
526 liveout_iterator Tmp = *this;
527 ++(*this);
528 return Tmp;
529 }
530
532 return *LiveRegI;
533 }
534
536 return &*LiveRegI;
537 }
538
539 bool operator==(const liveout_iterator &RHS) const {
540 if (BlockI != BlockEnd)
541 return BlockI == RHS.BlockI && LiveRegI == RHS.LiveRegI;
542 return RHS.BlockI == BlockEnd;
543 }
544
545 bool operator!=(const liveout_iterator &RHS) const {
546 return !(*this == RHS);
547 }
548 private:
549 bool advanceToValidPosition() {
550 if (LiveRegI != (*BlockI)->livein_end())
551 return true;
552
553 do {
554 ++BlockI;
555 } while (BlockI != BlockEnd && (*BlockI)->livein_empty());
556 if (BlockI == BlockEnd)
557 return false;
558
559 LiveRegI = (*BlockI)->livein_begin();
560 return true;
561 }
562
563 MCPhysReg ExceptionPointer, ExceptionSelector;
564 const_succ_iterator BlockI;
565 const_succ_iterator BlockEnd;
566 livein_iterator LiveRegI;
567 };
568
569 /// Iterator scanning successor basic blocks' liveins to determine the
570 /// registers potentially live at the end of this block. There may be
571 /// duplicates or overlapping registers in the list returned.
572 liveout_iterator liveout_begin() const;
574 return liveout_iterator(*this, 0, 0, true);
575 }
578 }
579
580 /// Get the clobber mask for the start of this basic block. Funclets use this
581 /// to prevent register allocation across funclet transitions.
583
584 /// Get the clobber mask for the end of the basic block.
585 /// \see getBeginClobberMask()
587
588 /// Return alignment of the basic block.
589 Align getAlignment() const { return Alignment; }
590
591 /// Set alignment of the basic block.
592 void setAlignment(Align A) { Alignment = A; }
593
594 void setAlignment(Align A, unsigned MaxBytes) {
596 setMaxBytesForAlignment(MaxBytes);
597 }
598
599 /// Return the maximum amount of padding allowed for aligning the basic block.
600 unsigned getMaxBytesForAlignment() const { return MaxBytesForAlignment; }
601
602 /// Set the maximum amount of padding allowed for aligning the basic block
603 void setMaxBytesForAlignment(unsigned MaxBytes) {
604 MaxBytesForAlignment = MaxBytes;
605 }
606
607 /// Returns true if the block is a landing pad. That is this basic block is
608 /// entered via an exception handler.
609 bool isEHPad() const { return IsEHPad; }
610
611 /// Indicates the block is a landing pad. That is this basic block is entered
612 /// via an exception handler.
613 void setIsEHPad(bool V = true) { IsEHPad = V; }
614
615 bool hasEHPadSuccessor() const;
616
617 /// Returns true if this is the entry block of the function.
618 bool isEntryBlock() const;
619
620 /// Returns true if this is the entry block of an EH scope, i.e., the block
621 /// that used to have a catchpad or cleanuppad instruction in the LLVM IR.
622 bool isEHScopeEntry() const { return IsEHScopeEntry; }
623
624 /// Indicates if this is the entry block of an EH scope, i.e., the block that
625 /// that used to have a catchpad or cleanuppad instruction in the LLVM IR.
626 void setIsEHScopeEntry(bool V = true) { IsEHScopeEntry = V; }
627
628 /// Returns true if this is a target block of a catchret.
629 bool isEHCatchretTarget() const { return IsEHCatchretTarget; }
630
631 /// Indicates if this is a target block of a catchret.
632 void setIsEHCatchretTarget(bool V = true) { IsEHCatchretTarget = V; }
633
634 /// Returns true if this is the entry block of an EH funclet.
635 bool isEHFuncletEntry() const { return IsEHFuncletEntry; }
636
637 /// Indicates if this is the entry block of an EH funclet.
638 void setIsEHFuncletEntry(bool V = true) { IsEHFuncletEntry = V; }
639
640 /// Returns true if this is the entry block of a cleanup funclet.
641 bool isCleanupFuncletEntry() const { return IsCleanupFuncletEntry; }
642
643 /// Indicates if this is the entry block of a cleanup funclet.
644 void setIsCleanupFuncletEntry(bool V = true) { IsCleanupFuncletEntry = V; }
645
646 /// Returns true if this block begins any section.
647 bool isBeginSection() const { return IsBeginSection; }
648
649 /// Returns true if this block ends any section.
650 bool isEndSection() const { return IsEndSection; }
651
652 void setIsBeginSection(bool V = true) { IsBeginSection = V; }
653
654 void setIsEndSection(bool V = true) { IsEndSection = V; }
655
656 std::optional<UniqueBBID> getBBID() const { return BBID; }
657
658 /// Returns the section ID of this basic block.
659 MBBSectionID getSectionID() const { return SectionID; }
660
661 /// Returns the unique section ID number of this basic block.
662 unsigned getSectionIDNum() const {
663 return ((unsigned)MBBSectionID::SectionType::Cold) -
664 ((unsigned)SectionID.Type) + SectionID.Number;
665 }
666
667 /// Sets the fixed BBID of this basic block.
668 void setBBID(const UniqueBBID &V) {
669 assert(!BBID.has_value() && "Cannot change BBID.");
670 BBID = V;
671 }
672
673 /// Sets the section ID for this basic block.
674 void setSectionID(MBBSectionID V) { SectionID = V; }
675
676 /// Returns the MCSymbol marking the end of this basic block.
677 MCSymbol *getEndSymbol() const;
678
679 /// Returns true if this block may have an INLINEASM_BR (overestimate, by
680 /// checking if any of the successors are indirect targets of any inlineasm_br
681 /// in the function).
682 bool mayHaveInlineAsmBr() const;
683
684 /// Returns true if this is the indirect dest of an INLINEASM_BR.
686 return IsInlineAsmBrIndirectTarget;
687 }
688
689 /// Indicates if this is the indirect dest of an INLINEASM_BR.
690 void setIsInlineAsmBrIndirectTarget(bool V = true) {
691 IsInlineAsmBrIndirectTarget = V;
692 }
693
694 /// Returns true if it is legal to hoist instructions into this block.
695 bool isLegalToHoistInto() const;
696
697 // Code Layout methods.
698
699 /// Move 'this' block before or after the specified block. This only moves
700 /// the block, it does not modify the CFG or adjust potential fall-throughs at
701 /// the end of the block.
702 void moveBefore(MachineBasicBlock *NewAfter);
703 void moveAfter(MachineBasicBlock *NewBefore);
704
705 /// Returns true if this and MBB belong to the same section.
706 bool sameSection(const MachineBasicBlock *MBB) const {
707 return getSectionID() == MBB->getSectionID();
708 }
709
710 /// Update the terminator instructions in block to account for changes to
711 /// block layout which may have been made. PreviousLayoutSuccessor should be
712 /// set to the block which may have been used as fallthrough before the block
713 /// layout was modified. If the block previously fell through to that block,
714 /// it may now need a branch. If it previously branched to another block, it
715 /// may now be able to fallthrough to the current layout successor.
716 void updateTerminator(MachineBasicBlock *PreviousLayoutSuccessor);
717
718 // Machine-CFG mutators
719
720 /// Add Succ as a successor of this MachineBasicBlock. The Predecessors list
721 /// of Succ is automatically updated. PROB parameter is stored in
722 /// Probabilities list. The default probability is set as unknown. Mixing
723 /// known and unknown probabilities in successor list is not allowed. When all
724 /// successors have unknown probabilities, 1 / N is returned as the
725 /// probability for each successor, where N is the number of successors.
726 ///
727 /// Note that duplicate Machine CFG edges are not allowed.
730
731 /// Add Succ as a successor of this MachineBasicBlock. The Predecessors list
732 /// of Succ is automatically updated. The probability is not provided because
733 /// BPI is not available (e.g. -O0 is used), in which case edge probabilities
734 /// won't be used. Using this interface can save some space.
736
737 /// Set successor probability of a given iterator.
739
740 /// Normalize probabilities of all successors so that the sum of them becomes
741 /// one. This is usually done when the current update on this MBB is done, and
742 /// the sum of its successors' probabilities is not guaranteed to be one. The
743 /// user is responsible for the correct use of this function.
744 /// MBB::removeSuccessor() has an option to do this automatically.
746 BranchProbability::normalizeProbabilities(Probs.begin(), Probs.end());
747 }
748
749 /// Validate successors' probabilities and check if the sum of them is
750 /// approximate one. This only works in DEBUG mode.
751 void validateSuccProbs() const;
752
753 /// Remove successor from the successors list of this MachineBasicBlock. The
754 /// Predecessors list of Succ is automatically updated.
755 /// If NormalizeSuccProbs is true, then normalize successors' probabilities
756 /// after the successor is removed.
758 bool NormalizeSuccProbs = false);
759
760 /// Remove specified successor from the successors list of this
761 /// MachineBasicBlock. The Predecessors list of Succ is automatically updated.
762 /// If NormalizeSuccProbs is true, then normalize successors' probabilities
763 /// after the successor is removed.
764 /// Return the iterator to the element after the one removed.
766 bool NormalizeSuccProbs = false);
767
768 /// Replace successor OLD with NEW and update probability info.
770
771 /// Copy a successor (and any probability info) from original block to this
772 /// block's. Uses an iterator into the original blocks successors.
773 ///
774 /// This is useful when doing a partial clone of successors. Afterward, the
775 /// probabilities may need to be normalized.
777
778 /// Split the old successor into old plus new and updates the probability
779 /// info.
781 bool NormalizeSuccProbs = false);
782
783 /// Transfers all the successors from MBB to this machine basic block (i.e.,
784 /// copies all the successors FromMBB and remove all the successors from
785 /// FromMBB).
787
788 /// Transfers all the successors, as in transferSuccessors, and update PHI
789 /// operands in the successor blocks which refer to FromMBB to refer to this.
791
792 /// Return true if any of the successors have probabilities attached to them.
793 bool hasSuccessorProbabilities() const { return !Probs.empty(); }
794
795 /// Return true if the specified MBB is a predecessor of this block.
796 bool isPredecessor(const MachineBasicBlock *MBB) const;
797
798 /// Return true if the specified MBB is a successor of this block.
799 bool isSuccessor(const MachineBasicBlock *MBB) const;
800
801 /// Return true if the specified MBB will be emitted immediately after this
802 /// block, such that if this block exits by falling through, control will
803 /// transfer to the specified MBB. Note that MBB need not be a successor at
804 /// all, for example if this block ends with an unconditional branch to some
805 /// other block.
806 bool isLayoutSuccessor(const MachineBasicBlock *MBB) const;
807
808 /// Return the successor of this block if it has a single successor.
809 /// Otherwise return a null pointer.
810 ///
813 return const_cast<MachineBasicBlock *>(
814 static_cast<const MachineBasicBlock *>(this)->getSingleSuccessor());
815 }
816
817 /// Return the predecessor of this block if it has a single predecessor.
818 /// Otherwise return a null pointer.
819 ///
822 return const_cast<MachineBasicBlock *>(
823 static_cast<const MachineBasicBlock *>(this)->getSinglePredecessor());
824 }
825
826 /// Return the fallthrough block if the block can implicitly
827 /// transfer control to the block after it by falling off the end of
828 /// it. If an explicit branch to the fallthrough block is not allowed,
829 /// set JumpToFallThrough to be false. Non-null return is a conservative
830 /// answer.
831 MachineBasicBlock *getFallThrough(bool JumpToFallThrough = true);
832
833 /// Return the fallthrough block if the block can implicitly
834 /// transfer control to it's successor, whether by a branch or
835 /// a fallthrough. Non-null return is a conservative answer.
837
838 /// Return true if the block can implicitly transfer control to the
839 /// block after it by falling off the end of it. This should return
840 /// false if it can reach the block after it, but it uses an
841 /// explicit branch to do so (e.g., a table jump). True is a
842 /// conservative answer.
843 bool canFallThrough();
844
845 /// Returns a pointer to the first instruction in this block that is not a
846 /// PHINode instruction. When adding instructions to the beginning of the
847 /// basic block, they should be added before the returned value, not before
848 /// the first instruction, which might be PHI.
849 /// Returns end() is there's no non-PHI instruction.
852 return const_cast<MachineBasicBlock *>(this)->getFirstNonPHI();
853 }
854
855 /// Return the first instruction in MBB after I that is not a PHI or a label.
856 /// This is the correct point to insert lowered copies at the beginning of a
857 /// basic block that must be before any debugging information.
859
860 /// Return the first instruction in MBB after I that is not a PHI, label or
861 /// debug. This is the correct point to insert copies at the beginning of a
862 /// basic block. \p Reg is the register being used by a spill or defined for a
863 /// restore/split during register allocation.
865 bool SkipPseudoOp = true);
866
867 /// Returns an iterator to the first terminator instruction of this basic
868 /// block. If a terminator does not exist, it returns end().
871 return const_cast<MachineBasicBlock *>(this)->getFirstTerminator();
872 }
873
874 /// Same getFirstTerminator but it ignores bundles and return an
875 /// instr_iterator instead.
877
878 /// Finds the first terminator in a block by scanning forward. This can handle
879 /// cases in GlobalISel where there may be non-terminator instructions between
880 /// terminators, for which getFirstTerminator() will not work correctly.
882
883 /// Returns an iterator to the first non-debug instruction in the basic block,
884 /// or end(). Skip any pseudo probe operation if \c SkipPseudoOp is true.
885 /// Pseudo probes are like debug instructions which do not turn into real
886 /// machine code. We try to use the function to skip both debug instructions
887 /// and pseudo probe operations to avoid API proliferation. This should work
888 /// most of the time when considering optimizing the rest of code in the
889 /// block, except for certain cases where pseudo probes are designed to block
890 /// the optimizations. For example, code merge like optimizations are supposed
891 /// to be blocked by pseudo probes for better AutoFDO profile quality.
892 /// Therefore, they should be considered as a valid instruction when this
893 /// function is called in a context of such optimizations. On the other hand,
894 /// \c SkipPseudoOp should be true when it's used in optimizations that
895 /// unlikely hurt profile quality, e.g., without block merging. The default
896 /// value of \c SkipPseudoOp is set to true to maximize code quality in
897 /// general, with an explict false value passed in in a few places like branch
898 /// folding and if-conversion to favor profile quality.
899 iterator getFirstNonDebugInstr(bool SkipPseudoOp = true);
900 const_iterator getFirstNonDebugInstr(bool SkipPseudoOp = true) const {
901 return const_cast<MachineBasicBlock *>(this)->getFirstNonDebugInstr(
902 SkipPseudoOp);
903 }
904
905 /// Returns an iterator to the last non-debug instruction in the basic block,
906 /// or end(). Skip any pseudo operation if \c SkipPseudoOp is true.
907 /// Pseudo probes are like debug instructions which do not turn into real
908 /// machine code. We try to use the function to skip both debug instructions
909 /// and pseudo probe operations to avoid API proliferation. This should work
910 /// most of the time when considering optimizing the rest of code in the
911 /// block, except for certain cases where pseudo probes are designed to block
912 /// the optimizations. For example, code merge like optimizations are supposed
913 /// to be blocked by pseudo probes for better AutoFDO profile quality.
914 /// Therefore, they should be considered as a valid instruction when this
915 /// function is called in a context of such optimizations. On the other hand,
916 /// \c SkipPseudoOp should be true when it's used in optimizations that
917 /// unlikely hurt profile quality, e.g., without block merging. The default
918 /// value of \c SkipPseudoOp is set to true to maximize code quality in
919 /// general, with an explict false value passed in in a few places like branch
920 /// folding and if-conversion to favor profile quality.
921 iterator getLastNonDebugInstr(bool SkipPseudoOp = true);
922 const_iterator getLastNonDebugInstr(bool SkipPseudoOp = true) const {
923 return const_cast<MachineBasicBlock *>(this)->getLastNonDebugInstr(
924 SkipPseudoOp);
925 }
926
927 /// Convenience function that returns true if the block ends in a return
928 /// instruction.
929 bool isReturnBlock() const {
930 return !empty() && back().isReturn();
931 }
932
933 /// Convenience function that returns true if the bock ends in a EH scope
934 /// return instruction.
935 bool isEHScopeReturnBlock() const {
936 return !empty() && back().isEHScopeReturn();
937 }
938
939 /// Split a basic block into 2 pieces at \p SplitPoint. A new block will be
940 /// inserted after this block, and all instructions after \p SplitInst moved
941 /// to it (\p SplitInst will be in the original block). If \p LIS is provided,
942 /// LiveIntervals will be appropriately updated. \return the newly inserted
943 /// block.
944 ///
945 /// If \p UpdateLiveIns is true, this will ensure the live ins list is
946 /// accurate, including for physreg uses/defs in the original block.
947 MachineBasicBlock *splitAt(MachineInstr &SplitInst, bool UpdateLiveIns = true,
948 LiveIntervals *LIS = nullptr);
949
950 /// Split the critical edge from this block to the given successor block, and
951 /// return the newly created block, or null if splitting is not possible.
952 ///
953 /// This function updates LiveVariables, MachineDominatorTree, and
954 /// MachineLoopInfo, as applicable.
957 std::vector<SparseBitVector<>> *LiveInSets = nullptr);
958
959 /// Check if the edge between this block and the given successor \p
960 /// Succ, can be split. If this returns true a subsequent call to
961 /// SplitCriticalEdge is guaranteed to return a valid basic block if
962 /// no changes occurred in the meantime.
963 bool canSplitCriticalEdge(const MachineBasicBlock *Succ) const;
964
965 void pop_front() { Insts.pop_front(); }
966 void pop_back() { Insts.pop_back(); }
967 void push_back(MachineInstr *MI) { Insts.push_back(MI); }
968
969 /// Insert MI into the instruction list before I, possibly inside a bundle.
970 ///
971 /// If the insertion point is inside a bundle, MI will be added to the bundle,
972 /// otherwise MI will not be added to any bundle. That means this function
973 /// alone can't be used to prepend or append instructions to bundles. See
974 /// MIBundleBuilder::insert() for a more reliable way of doing that.
976
977 /// Insert a range of instructions into the instruction list before I.
978 template<typename IT>
979 void insert(iterator I, IT S, IT E) {
980 assert((I == end() || I->getParent() == this) &&
981 "iterator points outside of basic block");
982 Insts.insert(I.getInstrIterator(), S, E);
983 }
984
985 /// Insert MI into the instruction list before I.
987 assert((I == end() || I->getParent() == this) &&
988 "iterator points outside of basic block");
989 assert(!MI->isBundledWithPred() && !MI->isBundledWithSucc() &&
990 "Cannot insert instruction with bundle flags");
991 return Insts.insert(I.getInstrIterator(), MI);
992 }
993
994 /// Insert MI into the instruction list after I.
996 assert((I == end() || I->getParent() == this) &&
997 "iterator points outside of basic block");
998 assert(!MI->isBundledWithPred() && !MI->isBundledWithSucc() &&
999 "Cannot insert instruction with bundle flags");
1000 return Insts.insertAfter(I.getInstrIterator(), MI);
1001 }
1002
1003 /// If I is bundled then insert MI into the instruction list after the end of
1004 /// the bundle, otherwise insert MI immediately after I.
1006 assert((I == instr_end() || I->getParent() == this) &&
1007 "iterator points outside of basic block");
1008 assert(!MI->isBundledWithPred() && !MI->isBundledWithSucc() &&
1009 "Cannot insert instruction with bundle flags");
1010 while (I->isBundledWithSucc())
1011 ++I;
1012 return Insts.insertAfter(I, MI);
1013 }
1014
1015 /// Remove an instruction from the instruction list and delete it.
1016 ///
1017 /// If the instruction is part of a bundle, the other instructions in the
1018 /// bundle will still be bundled after removing the single instruction.
1020
1021 /// Remove an instruction from the instruction list and delete it.
1022 ///
1023 /// If the instruction is part of a bundle, the other instructions in the
1024 /// bundle will still be bundled after removing the single instruction.
1026 return erase(instr_iterator(I));
1027 }
1028
1029 /// Remove a range of instructions from the instruction list and delete them.
1031 return Insts.erase(I.getInstrIterator(), E.getInstrIterator());
1032 }
1033
1034 /// Remove an instruction or bundle from the instruction list and delete it.
1035 ///
1036 /// If I points to a bundle of instructions, they are all erased.
1038 return erase(I, std::next(I));
1039 }
1040
1041 /// Remove an instruction from the instruction list and delete it.
1042 ///
1043 /// If I is the head of a bundle of instructions, the whole bundle will be
1044 /// erased.
1046 return erase(iterator(I));
1047 }
1048
1049 /// Remove the unbundled instruction from the instruction list without
1050 /// deleting it.
1051 ///
1052 /// This function can not be used to remove bundled instructions, use
1053 /// remove_instr to remove individual instructions from a bundle.
1055 assert(!I->isBundled() && "Cannot remove bundled instructions");
1056 return Insts.remove(instr_iterator(I));
1057 }
1058
1059 /// Remove the possibly bundled instruction from the instruction list
1060 /// without deleting it.
1061 ///
1062 /// If the instruction is part of a bundle, the other instructions in the
1063 /// bundle will still be bundled after removing the single instruction.
1065
1066 void clear() {
1067 Insts.clear();
1068 }
1069
1070 /// Take an instruction from MBB 'Other' at the position From, and insert it
1071 /// into this MBB right before 'Where'.
1072 ///
1073 /// If From points to a bundle of instructions, the whole bundle is moved.
1075 // The range splice() doesn't allow noop moves, but this one does.
1076 if (Where != From)
1077 splice(Where, Other, From, std::next(From));
1078 }
1079
1080 /// Take a block of instructions from MBB 'Other' in the range [From, To),
1081 /// and insert them into this MBB right before 'Where'.
1082 ///
1083 /// The instruction at 'Where' must not be included in the range of
1084 /// instructions to move.
1086 iterator From, iterator To) {
1087 Insts.splice(Where.getInstrIterator(), Other->Insts,
1088 From.getInstrIterator(), To.getInstrIterator());
1089 }
1090
1091 /// This method unlinks 'this' from the containing function, and returns it,
1092 /// but does not delete it.
1094
1095 /// This method unlinks 'this' from the containing function and deletes it.
1096 void eraseFromParent();
1097
1098 /// Given a machine basic block that branched to 'Old', change the code and
1099 /// CFG so that it branches to 'New' instead.
1101
1102 /// Update all phi nodes in this basic block to refer to basic block \p New
1103 /// instead of basic block \p Old.
1105
1106 /// Find the next valid DebugLoc starting at MBBI, skipping any debug
1107 /// instructions. Return UnknownLoc if there is none.
1110 return findDebugLoc(MBBI.getInstrIterator());
1111 }
1112
1113 /// Has exact same behavior as @ref findDebugLoc (it also searches towards the
1114 /// end of this MBB) except that this function takes a reverse iterator to
1115 /// identify the starting MI.
1118 return rfindDebugLoc(MBBI.getInstrIterator());
1119 }
1120
1121 /// Find the previous valid DebugLoc preceding MBBI, skipping any debug
1122 /// instructions. It is possible to find the last DebugLoc in the MBB using
1123 /// findPrevDebugLoc(instr_end()). Return UnknownLoc if there is none.
1126 return findPrevDebugLoc(MBBI.getInstrIterator());
1127 }
1128
1129 /// Has exact same behavior as @ref findPrevDebugLoc (it also searches towards
1130 /// the beginning of this MBB) except that this function takes reverse
1131 /// iterator to identify the starting MI. A minor difference compared to
1132 /// findPrevDebugLoc is that we can't start scanning at "instr_end".
1135 return rfindPrevDebugLoc(MBBI.getInstrIterator());
1136 }
1137
1138 /// Find and return the merged DebugLoc of the branch instructions of the
1139 /// block. Return UnknownLoc if there is none.
1141
1142 /// Possible outcome of a register liveness query to computeRegisterLiveness()
1144 LQR_Live, ///< Register is known to be (at least partially) live.
1145 LQR_Dead, ///< Register is known to be fully dead.
1146 LQR_Unknown ///< Register liveness not decidable from local neighborhood.
1148
1149 /// Return whether (physical) register \p Reg has been defined and not
1150 /// killed as of just before \p Before.
1151 ///
1152 /// Search is localised to a neighborhood of \p Neighborhood instructions
1153 /// before (searching for defs or kills) and \p Neighborhood instructions
1154 /// after (searching just for defs) \p Before.
1155 ///
1156 /// \p Reg must be a physical register.
1160 unsigned Neighborhood = 10) const;
1161
1162 // Debugging methods.
1163 void dump() const;
1164 void print(raw_ostream &OS, const SlotIndexes * = nullptr,
1165 bool IsStandalone = true) const;
1167 const SlotIndexes * = nullptr, bool IsStandalone = true) const;
1168
1170 PrintNameIr = (1 << 0), ///< Add IR name where available
1171 PrintNameAttributes = (1 << 1), ///< Print attributes
1172 };
1173
1174 void printName(raw_ostream &os, unsigned printNameFlags = PrintNameIr,
1175 ModuleSlotTracker *moduleSlotTracker = nullptr) const;
1176
1177 // Printing method used by LoopInfo.
1178 void printAsOperand(raw_ostream &OS, bool PrintType = true) const;
1179
1180 /// MachineBasicBlocks are uniquely numbered at the function level, unless
1181 /// they're not in a MachineFunction yet, in which case this will return -1.
1182 int getNumber() const { return Number; }
1183 void setNumber(int N) { Number = N; }
1184
1185 /// Return the call frame size on entry to this basic block.
1186 unsigned getCallFrameSize() const { return CallFrameSize; }
1187 /// Set the call frame size on entry to this basic block.
1188 void setCallFrameSize(unsigned N) { CallFrameSize = N; }
1189
1190 /// Return the MCSymbol for this basic block.
1191 MCSymbol *getSymbol() const;
1192
1193 /// Return the EHCatchret Symbol for this basic block.
1195
1196 std::optional<uint64_t> getIrrLoopHeaderWeight() const {
1197 return IrrLoopHeaderWeight;
1198 }
1199
1201 IrrLoopHeaderWeight = Weight;
1202 }
1203
1204 /// Return probability of the edge from this block to MBB. This method should
1205 /// NOT be called directly, but by using getEdgeProbability method from
1206 /// MachineBranchProbabilityInfo class.
1208
1209private:
1210 /// Return probability iterator corresponding to the I successor iterator.
1211 probability_iterator getProbabilityIterator(succ_iterator I);
1212 const_probability_iterator
1213 getProbabilityIterator(const_succ_iterator I) const;
1214
1216 friend class MIPrinter;
1217
1218 // Methods used to maintain doubly linked list of blocks...
1220
1221 // Machine-CFG mutators
1222
1223 /// Add Pred as a predecessor of this MachineBasicBlock. Don't do this
1224 /// unless you know what you're doing, because it doesn't update Pred's
1225 /// successors list. Use Pred->addSuccessor instead.
1226 void addPredecessor(MachineBasicBlock *Pred);
1227
1228 /// Remove Pred as a predecessor of this MachineBasicBlock. Don't do this
1229 /// unless you know what you're doing, because it doesn't update Pred's
1230 /// successors list. Use Pred->removeSuccessor instead.
1231 void removePredecessor(MachineBasicBlock *Pred);
1232};
1233
1235
1236/// Prints a machine basic block reference.
1237///
1238/// The format is:
1239/// %bb.5 - a machine basic block with MBB.getNumber() == 5.
1240///
1241/// Usage: OS << printMBBReference(MBB) << '\n';
1243
1244// This is useful when building IndexedMaps keyed on basic block pointers.
1247 unsigned operator()(const MachineBasicBlock *MBB) const {
1248 return MBB->getNumber();
1249 }
1250};
1251
1252//===--------------------------------------------------------------------===//
1253// GraphTraits specializations for machine basic block graphs (machine-CFGs)
1254//===--------------------------------------------------------------------===//
1255
1256// Provide specializations of GraphTraits to be able to treat a
1257// MachineFunction as a graph of MachineBasicBlocks.
1258//
1259
1260template <> struct GraphTraits<MachineBasicBlock *> {
1263
1264 static NodeRef getEntryNode(MachineBasicBlock *BB) { return BB; }
1265 static ChildIteratorType child_begin(NodeRef N) { return N->succ_begin(); }
1266 static ChildIteratorType child_end(NodeRef N) { return N->succ_end(); }
1267};
1268
1269template <> struct GraphTraits<const MachineBasicBlock *> {
1272
1273 static NodeRef getEntryNode(const MachineBasicBlock *BB) { return BB; }
1274 static ChildIteratorType child_begin(NodeRef N) { return N->succ_begin(); }
1275 static ChildIteratorType child_end(NodeRef N) { return N->succ_end(); }
1276};
1277
1278// Provide specializations of GraphTraits to be able to treat a
1279// MachineFunction as a graph of MachineBasicBlocks and to walk it
1280// in inverse order. Inverse order for a function is considered
1281// to be when traversing the predecessor edges of a MBB
1282// instead of the successor edges.
1283//
1287
1289 return G.Graph;
1290 }
1291
1292 static ChildIteratorType child_begin(NodeRef N) { return N->pred_begin(); }
1293 static ChildIteratorType child_end(NodeRef N) { return N->pred_end(); }
1294};
1295
1299
1301 return G.Graph;
1302 }
1303
1304 static ChildIteratorType child_begin(NodeRef N) { return N->pred_begin(); }
1305 static ChildIteratorType child_end(NodeRef N) { return N->pred_end(); }
1306};
1307
1308// These accessors are handy for sharing templated code between IR and MIR.
1309inline auto successors(const MachineBasicBlock *BB) { return BB->successors(); }
1310inline auto predecessors(const MachineBasicBlock *BB) {
1311 return BB->predecessors();
1312}
1313
1314/// MachineInstrSpan provides an interface to get an iteration range
1315/// containing the instruction it was initialized with, along with all
1316/// those instructions inserted prior to or following that instruction
1317/// at some point after the MachineInstrSpan is constructed.
1319 MachineBasicBlock &MBB;
1321
1322public:
1324 : MBB(*BB), I(I), B(I == MBB.begin() ? MBB.end() : std::prev(I)),
1325 E(std::next(I)) {
1326 assert(I == BB->end() || I->getParent() == BB);
1327 }
1328
1330 return B == MBB.end() ? MBB.begin() : std::next(B);
1331 }
1333 bool empty() { return begin() == end(); }
1334
1336};
1337
1338/// Increment \p It until it points to a non-debug instruction or to \p End
1339/// and return the resulting iterator. This function should only be used
1340/// MachineBasicBlock::{iterator, const_iterator, instr_iterator,
1341/// const_instr_iterator} and the respective reverse iterators.
1342template <typename IterT>
1343inline IterT skipDebugInstructionsForward(IterT It, IterT End,
1344 bool SkipPseudoOp = true) {
1345 while (It != End &&
1346 (It->isDebugInstr() || (SkipPseudoOp && It->isPseudoProbe())))
1347 ++It;
1348 return It;
1349}
1350
1351/// Decrement \p It until it points to a non-debug instruction or to \p Begin
1352/// and return the resulting iterator. This function should only be used
1353/// MachineBasicBlock::{iterator, const_iterator, instr_iterator,
1354/// const_instr_iterator} and the respective reverse iterators.
1355template <class IterT>
1356inline IterT skipDebugInstructionsBackward(IterT It, IterT Begin,
1357 bool SkipPseudoOp = true) {
1358 while (It != Begin &&
1359 (It->isDebugInstr() || (SkipPseudoOp && It->isPseudoProbe())))
1360 --It;
1361 return It;
1362}
1363
1364/// Increment \p It, then continue incrementing it while it points to a debug
1365/// instruction. A replacement for std::next.
1366template <typename IterT>
1367inline IterT next_nodbg(IterT It, IterT End, bool SkipPseudoOp = true) {
1368 return skipDebugInstructionsForward(std::next(It), End, SkipPseudoOp);
1369}
1370
1371/// Decrement \p It, then continue decrementing it while it points to a debug
1372/// instruction. A replacement for std::prev.
1373template <typename IterT>
1374inline IterT prev_nodbg(IterT It, IterT Begin, bool SkipPseudoOp = true) {
1375 return skipDebugInstructionsBackward(std::prev(It), Begin, SkipPseudoOp);
1376}
1377
1378/// Construct a range iterator which begins at \p It and moves forwards until
1379/// \p End is reached, skipping any debug instructions.
1380template <typename IterT>
1381inline auto instructionsWithoutDebug(IterT It, IterT End,
1382 bool SkipPseudoOp = true) {
1383 return make_filter_range(make_range(It, End), [=](const MachineInstr &MI) {
1384 return !MI.isDebugInstr() && !(SkipPseudoOp && MI.isPseudoProbe());
1385 });
1386}
1387
1388} // end namespace llvm
1389
1390#endif // LLVM_CODEGEN_MACHINEBASICBLOCK_H
aarch64 AArch64 CCMP Pass
aarch64 promote const
MachineBasicBlock & MBB
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")
bool End
Definition: ELF_riscv.cpp:480
This file defines the little GraphTraits<X> template class that should be specialized by classes that...
IRTranslator LLVM IR MI
A common definition of LaneBitmask for use in TableGen and CodeGen.
#define I(x, y, z)
Definition: MD5.cpp:58
#define G(x, y, z)
Definition: MD5.cpp:56
unsigned const TargetRegisterInfo * TRI
unsigned Reg
#define P(N)
uint32_t Number
Definition: Profile.cpp:47
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
raw_pwrite_stream & OS
This file defines the SparseBitVector class.
Value * RHS
LLVM Basic Block Representation.
Definition: BasicBlock.h:61
static BranchProbability getUnknown()
static void normalizeProbabilities(ProbabilityIter Begin, ProbabilityIter End)
A debug info location.
Definition: DebugLoc.h:33
Wrapper class representing physical registers. Should be passed by value.
Definition: MCRegister.h:33
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
This class prints out the machine instructions using the MIR serialization format.
Definition: MIRPrinter.cpp:140
liveout_iterator(const MachineBasicBlock &MBB, MCPhysReg ExceptionPointer, MCPhysReg ExceptionSelector, bool End)
bool operator==(const liveout_iterator &RHS) 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
std::vector< MachineBasicBlock * >::const_reverse_iterator const_pred_reverse_iterator
unsigned pred_size() const
void transferSuccessorsAndUpdatePHIs(MachineBasicBlock *FromMBB)
Transfers all the successors, as in transferSuccessors, and update PHI operands in the successor bloc...
std::vector< MachineBasicBlock * >::reverse_iterator succ_reverse_iterator
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.
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.
std::vector< MachineBasicBlock * >::reverse_iterator pred_reverse_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.
reverse_iterator rend()
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...
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
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()
std::vector< MachineBasicBlock * >::const_iterator const_succ_iterator
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.
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...
std::vector< MachineBasicBlock * >::const_iterator const_pred_iterator
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.
std::vector< MachineBasicBlock * >::const_reverse_iterator const_succ_reverse_iterator
bool isLiveIn(MCPhysReg Reg, LaneBitmask LaneMask=LaneBitmask::getAll()) const
Return true if the specified register is in the live in set.
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().
DebugLoc rfindDebugLoc(reverse_iterator MBBI)
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 ...
std::vector< MachineBasicBlock * >::iterator succ_iterator
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.
const_pred_reverse_iterator pred_rbegin() const
void addLiveIn(const RegisterMaskPair &RegMaskPair)
MachineBasicBlock * getSingleSuccessor()
BasicBlock * getAddressTakenIRBlock() const
Retrieves the BasicBlock which corresponds to this MachineBasicBlock.
unsigned getSectionIDNum() const
Returns the unique section ID number of this basic block.
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)
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
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
MachineBasicBlock * SplitCriticalEdge(MachineBasicBlock *Succ, Pass &P, std::vector< SparseBitVector<> > *LiveInSets=nullptr)
Split the critical edge from this block to the given successor block, and return the newly created bl...
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.
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()
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.
bool mayHaveInlineAsmBr() const
Returns true if this block may have an INLINEASM_BR (overestimate, by checking if any of the successo...
void removeLiveIn(MCPhysReg Reg, LaneBitmask LaneMask=LaneBitmask::getAll())
Remove the specified register from the live in set.
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
std::vector< MachineBasicBlock * >::iterator pred_iterator
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
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.
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.
Definition: MachineInstr.h:69
bool isReturn(QueryType Type=AnyInBundle) const
Definition: MachineInstr.h:940
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...
Definition: MachineInstr.h:946
Manage lifetime of a slot tracker for printing IR.
Pass interface - Implemented by all 'passes'.
Definition: Pass.h:94
Simple wrapper around std::function<void(raw_ostream&)>.
Definition: Printable.h:38
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
SlotIndexes pass.
Definition: SlotIndexes.h:296
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
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.
Definition: Type.h:45
An ilist node that can access its parent list.
Definition: ilist_node.h:321
base_list_type::const_reverse_iterator const_reverse_iterator
Definition: ilist.h:125
An intrusive list with ownership and callbacks specified/controlled by ilist_traits,...
Definition: ilist.h:328
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
A simple intrusive list implementation.
Definition: simple_ilist.h:81
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.
Definition: ISDOpcodes.h:71
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
IterT next_nodbg(IterT It, IterT End, bool SkipPseudoOp=true)
Increment It, then continue incrementing it while it points to a debug instruction.
auto successors(const MachineBasicBlock *BB)
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
Definition: MCRegister.h:21
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
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.
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...
Definition: STLExtras.h:572
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...
@ Other
Any other memory.
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Definition: APFixedPoint.h:293
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.
Definition: BitVector.h:858
#define N
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
static NodeRef getEntryNode(Inverse< MachineBasicBlock * > G)
static ChildIteratorType child_begin(NodeRef N)
static NodeRef getEntryNode(Inverse< const MachineBasicBlock * > G)
MachineBasicBlock::const_pred_iterator ChildIteratorType
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 NodeRef getEntryNode(const MachineBasicBlock *BB)
static ChildIteratorType child_end(NodeRef N)
static constexpr LaneBitmask getAll()
Definition: LaneBitmask.h:82
unsigned operator()(const MachineBasicBlock *MBB) const
bool operator!=(const MBBSectionID &Other) const
static const MBBSectionID ExceptionSectionID
static const MBBSectionID ColdSectionID
MBBSectionID(unsigned N)
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.
Definition: ilist.h:65
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.
Definition: ilist.h:90