LLVM 20.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
19#include "llvm/ADT/ilist.h"
23#include "llvm/IR/DebugLoc.h"
24#include "llvm/MC/LaneBitmask.h"
26#include <cassert>
27#include <cstdint>
28#include <iterator>
29#include <string>
30#include <vector>
31
32namespace llvm {
33
34class BasicBlock;
35class MachineFunction;
36class MCSymbol;
37class ModuleSlotTracker;
38class Pass;
39class Printable;
40class SlotIndexes;
41class StringRef;
42class raw_ostream;
43class LiveIntervals;
44class TargetRegisterClass;
45class TargetRegisterInfo;
46template <typename IRUnitT, typename... ExtraArgTs> class AnalysisManager;
48
49// This structure uniquely identifies a basic block section.
50// Possible values are
51// {Type: Default, Number: (unsigned)} (These are regular section IDs)
52// {Type: Exception, Number: 0} (ExceptionSectionID)
53// {Type: Cold, Number: 0} (ColdSectionID)
56 Default = 0, // Regular section (these sections are distinguished by the
57 // Number field).
58 Exception, // Special section type for exception handling blocks
59 Cold, // Special section type for cold blocks
61 unsigned Number;
62
63 MBBSectionID(unsigned N) : Type(Default), Number(N) {}
64
65 // Special unique sections for cold and exception blocks.
68
69 bool operator==(const MBBSectionID &Other) const {
70 return Type == Other.Type && Number == Other.Number;
71 }
72
73 bool operator!=(const MBBSectionID &Other) const { return !(*this == Other); }
74
75private:
76 // This is only used to construct the special cold and exception sections.
78};
79
80template <> struct DenseMapInfo<MBBSectionID> {
83
84 static inline MBBSectionID getEmptyKey() {
85 return MBBSectionID(NumberInfo::getEmptyKey());
86 }
87 static inline MBBSectionID getTombstoneKey() {
88 return MBBSectionID(NumberInfo::getTombstoneKey());
89 }
90 static unsigned getHashValue(const MBBSectionID &SecID) {
91 return detail::combineHashValue(TypeInfo::getHashValue(SecID.Type),
92 NumberInfo::getHashValue(SecID.Number));
93 }
94 static bool isEqual(const MBBSectionID &LHS, const MBBSectionID &RHS) {
95 return LHS == RHS;
96 }
97};
98
99// This structure represents the information for a basic block pertaining to
100// the basic block sections profile.
102 unsigned BaseID;
103 unsigned CloneID;
104};
105
106template <> struct ilist_traits<MachineInstr> {
107private:
108 friend class MachineBasicBlock; // Set by the owning MachineBasicBlock.
109
110 MachineBasicBlock *Parent;
111
112 using instr_iterator =
114
115public:
118 void transferNodesFromList(ilist_traits &FromList, instr_iterator First,
119 instr_iterator Last);
121};
122
124 : public ilist_node_with_parent<MachineBasicBlock, MachineFunction> {
125public:
126 /// Pair of physical register and lane mask.
127 /// This is not simply a std::pair typedef because the members should be named
128 /// clearly as they both have an integer type.
130 public:
133
136
137 bool operator==(const RegisterMaskPair &other) const {
138 return PhysReg == other.PhysReg && LaneMask == other.LaneMask;
139 }
140 };
141
142private:
144
145 const BasicBlock *BB;
146 int Number;
147
148 /// The call frame size on entry to this basic block due to call frame setup
149 /// instructions in a predecessor. This is usually zero, unless basic blocks
150 /// are split in the middle of a call sequence.
151 ///
152 /// This information is only maintained until PrologEpilogInserter eliminates
153 /// call frame pseudos.
154 unsigned CallFrameSize = 0;
155
156 MachineFunction *xParent;
157 Instructions Insts;
158
159 /// Keep track of the predecessor / successor basic blocks.
162
163 /// Keep track of the probabilities to the successors. This vector has the
164 /// same order as Successors, or it is empty if we don't use it (disable
165 /// optimization).
166 std::vector<BranchProbability> Probs;
167 using probability_iterator = std::vector<BranchProbability>::iterator;
168 using const_probability_iterator =
169 std::vector<BranchProbability>::const_iterator;
170
171 std::optional<uint64_t> IrrLoopHeaderWeight;
172
173 /// Keep track of the physical registers that are livein of the basicblock.
174 using LiveInVector = std::vector<RegisterMaskPair>;
175 LiveInVector LiveIns;
176
177 /// Alignment of the basic block. One if the basic block does not need to be
178 /// aligned.
179 Align Alignment;
180 /// Maximum amount of bytes that can be added to align the basic block. If the
181 /// alignment cannot be reached in this many bytes, no bytes are emitted.
182 /// Zero to represent no maximum.
183 unsigned MaxBytesForAlignment = 0;
184
185 /// Indicate that this basic block is entered via an exception handler.
186 bool IsEHPad = false;
187
188 /// Indicate that this MachineBasicBlock is referenced somewhere other than
189 /// as predecessor/successor, a terminator MachineInstr, or a jump table.
190 bool MachineBlockAddressTaken = false;
191
192 /// If this MachineBasicBlock corresponds to an IR-level "blockaddress"
193 /// constant, this contains a pointer to that block.
194 BasicBlock *AddressTakenIRBlock = nullptr;
195
196 /// Indicate that this basic block needs its symbol be emitted regardless of
197 /// whether the flow just falls-through to it.
198 bool LabelMustBeEmitted = false;
199
200 /// Indicate that this basic block is the entry block of an EH scope, i.e.,
201 /// the block that used to have a catchpad or cleanuppad instruction in the
202 /// LLVM IR.
203 bool IsEHScopeEntry = false;
204
205 /// Indicates if this is a target block of a catchret.
206 bool IsEHCatchretTarget = false;
207
208 /// Indicate that this basic block is the entry block of an EH funclet.
209 bool IsEHFuncletEntry = false;
210
211 /// Indicate that this basic block is the entry block of a cleanup funclet.
212 bool IsCleanupFuncletEntry = false;
213
214 /// Fixed unique ID assigned to this basic block upon creation. Used with
215 /// basic block sections and basic block labels.
216 std::optional<UniqueBBID> BBID;
217
218 /// With basic block sections, this stores the Section ID of the basic block.
219 MBBSectionID SectionID{0};
220
221 // Indicate that this basic block begins a section.
222 bool IsBeginSection = false;
223
224 // Indicate that this basic block ends a section.
225 bool IsEndSection = false;
226
227 /// Indicate that this basic block is the indirect dest of an INLINEASM_BR.
228 bool IsInlineAsmBrIndirectTarget = false;
229
230 /// since getSymbol is a relatively heavy-weight operation, the symbol
231 /// is only computed once and is cached.
232 mutable MCSymbol *CachedMCSymbol = nullptr;
233
234 /// Cached MCSymbol for this block (used if IsEHCatchRetTarget).
235 mutable MCSymbol *CachedEHCatchretMCSymbol = nullptr;
236
237 /// Marks the end of the basic block. Used during basic block sections to
238 /// calculate the size of the basic block, or the BB section ending with it.
239 mutable MCSymbol *CachedEndMCSymbol = nullptr;
240
241 // Intrusive list support
242 MachineBasicBlock() = default;
243
244 explicit MachineBasicBlock(MachineFunction &MF, const BasicBlock *BB);
245
246 ~MachineBasicBlock();
247
248 // MachineBasicBlocks are allocated and owned by MachineFunction.
249 friend class MachineFunction;
250
251public:
252 /// Return the LLVM basic block that this instance corresponded to originally.
253 /// Note that this may be NULL if this instance does not correspond directly
254 /// to an LLVM basic block.
255 const BasicBlock *getBasicBlock() const { return BB; }
256
257 /// Remove the reference to the underlying IR BasicBlock. This is for
258 /// reduction tools and should generally not be used.
260 BB = nullptr;
261 }
262
263 /// Check if there is a name of corresponding LLVM basic block.
264 bool hasName() const;
265
266 /// Return the name of the corresponding LLVM basic block, or an empty string.
267 StringRef getName() const;
268
269 /// Return a formatted string to identify this block and its parent function.
270 std::string getFullName() const;
271
272 /// Test whether this block is used as something other than the target
273 /// of a terminator, exception-handling target, or jump table. This is
274 /// either the result of an IR-level "blockaddress", or some form
275 /// of target-specific branch lowering.
276 bool hasAddressTaken() const {
277 return MachineBlockAddressTaken || AddressTakenIRBlock;
278 }
279
280 /// Test whether this block is used as something other than the target of a
281 /// terminator, exception-handling target, jump table, or IR blockaddress.
282 /// For example, its address might be loaded into a register, or
283 /// stored in some branch table that isn't part of MachineJumpTableInfo.
284 bool isMachineBlockAddressTaken() const { return MachineBlockAddressTaken; }
285
286 /// Test whether this block is the target of an IR BlockAddress. (There can
287 /// more than one MBB associated with an IR BB where the address is taken.)
288 bool isIRBlockAddressTaken() const { return AddressTakenIRBlock; }
289
290 /// Retrieves the BasicBlock which corresponds to this MachineBasicBlock.
291 BasicBlock *getAddressTakenIRBlock() const { return AddressTakenIRBlock; }
292
293 /// Set this block to indicate that its address is used as something other
294 /// than the target of a terminator, exception-handling target, jump table,
295 /// or IR-level "blockaddress".
296 void setMachineBlockAddressTaken() { MachineBlockAddressTaken = true; }
297
298 /// Set this block to reflect that it corresponds to an IR-level basic block
299 /// with a BlockAddress.
300 void setAddressTakenIRBlock(BasicBlock *BB) { AddressTakenIRBlock = BB; }
301
302 /// Test whether this block must have its label emitted.
303 bool hasLabelMustBeEmitted() const { return LabelMustBeEmitted; }
304
305 /// Set this block to reflect that, regardless how we flow to it, we need
306 /// its label be emitted.
307 void setLabelMustBeEmitted() { LabelMustBeEmitted = true; }
308
309 /// Return the MachineFunction containing this basic block.
310 const MachineFunction *getParent() const { return xParent; }
311 MachineFunction *getParent() { return xParent; }
312
317
323
324 unsigned size() const { return (unsigned)Insts.size(); }
325 bool sizeWithoutDebugLargerThan(unsigned Limit) const;
326 bool empty() const { return Insts.empty(); }
327
328 MachineInstr &instr_front() { return Insts.front(); }
329 MachineInstr &instr_back() { return Insts.back(); }
330 const MachineInstr &instr_front() const { return Insts.front(); }
331 const MachineInstr &instr_back() const { return Insts.back(); }
332
333 MachineInstr &front() { return Insts.front(); }
334 MachineInstr &back() { return *--end(); }
335 const MachineInstr &front() const { return Insts.front(); }
336 const MachineInstr &back() const { return *--end(); }
337
338 instr_iterator instr_begin() { return Insts.begin(); }
339 const_instr_iterator instr_begin() const { return Insts.begin(); }
340 instr_iterator instr_end() { return Insts.end(); }
341 const_instr_iterator instr_end() const { return Insts.end(); }
342 reverse_instr_iterator instr_rbegin() { return Insts.rbegin(); }
343 const_reverse_instr_iterator instr_rbegin() const { return Insts.rbegin(); }
344 reverse_instr_iterator instr_rend () { return Insts.rend(); }
345 const_reverse_instr_iterator instr_rend () const { return Insts.rend(); }
346
352 }
353
354 iterator begin() { return instr_begin(); }
355 const_iterator begin() const { return instr_begin(); }
356 iterator end () { return instr_end(); }
357 const_iterator end () const { return instr_end(); }
360 }
363 }
367 }
368
369 /// Support for MachineInstr::getNextNode().
371 return &MachineBasicBlock::Insts;
372 }
373
375 return make_range(getFirstTerminator(), end());
376 }
378 return make_range(getFirstTerminator(), end());
379 }
380
381 /// Returns a range that iterates over the phis in the basic block.
383 return make_range(begin(), getFirstNonPHI());
384 }
386 return const_cast<MachineBasicBlock *>(this)->phis();
387 }
388
389 // Machine-CFG iterators
404 pred_iterator pred_begin() { return Predecessors.begin(); }
405 const_pred_iterator pred_begin() const { return Predecessors.begin(); }
406 pred_iterator pred_end() { return Predecessors.end(); }
407 const_pred_iterator pred_end() const { return Predecessors.end(); }
409 { return Predecessors.rbegin();}
411 { return Predecessors.rbegin();}
413 { return Predecessors.rend(); }
415 { return Predecessors.rend(); }
416 unsigned pred_size() const {
417 return (unsigned)Predecessors.size();
418 }
419 bool pred_empty() const { return Predecessors.empty(); }
420 succ_iterator succ_begin() { return Successors.begin(); }
421 const_succ_iterator succ_begin() const { return Successors.begin(); }
422 succ_iterator succ_end() { return Successors.end(); }
423 const_succ_iterator succ_end() const { return Successors.end(); }
425 { return Successors.rbegin(); }
427 { return Successors.rbegin(); }
429 { return Successors.rend(); }
431 { return Successors.rend(); }
432 unsigned succ_size() const {
433 return (unsigned)Successors.size();
434 }
435 bool succ_empty() const { return Successors.empty(); }
436
438 return make_range(pred_begin(), pred_end());
439 }
441 return make_range(pred_begin(), pred_end());
442 }
444 return make_range(succ_begin(), succ_end());
445 }
447 return make_range(succ_begin(), succ_end());
448 }
449
450 // LiveIn management methods.
451
452 /// Adds the specified register as a live in. Note that it is an error to add
453 /// the same register to the same set more than once unless the intention is
454 /// to call sortUniqueLiveIns after all registers are added.
455 void addLiveIn(MCRegister PhysReg,
456 LaneBitmask LaneMask = LaneBitmask::getAll()) {
457 LiveIns.push_back(RegisterMaskPair(PhysReg, LaneMask));
458 }
459 void addLiveIn(const RegisterMaskPair &RegMaskPair) {
460 LiveIns.push_back(RegMaskPair);
461 }
462
463 /// Sorts and uniques the LiveIns vector. It can be significantly faster to do
464 /// this than repeatedly calling isLiveIn before calling addLiveIn for every
465 /// LiveIn insertion.
466 void sortUniqueLiveIns();
467
468 /// Clear live in list.
469 void clearLiveIns();
470
471 /// Clear the live in list, and return the removed live in's in \p OldLiveIns.
472 /// Requires that the vector \p OldLiveIns is empty.
473 void clearLiveIns(std::vector<RegisterMaskPair> &OldLiveIns);
474
475 /// Add PhysReg as live in to this block, and ensure that there is a copy of
476 /// PhysReg to a virtual register of class RC. Return the virtual register
477 /// that is a copy of the live in PhysReg.
479
480 /// Remove the specified register from the live in set.
482 LaneBitmask LaneMask = LaneBitmask::getAll());
483
484 /// Return true if the specified register is in the live in set.
486 LaneBitmask LaneMask = LaneBitmask::getAll()) const;
487
488 // Iteration support for live in sets. These sets are kept in sorted
489 // order by their register number.
490 using livein_iterator = LiveInVector::const_iterator;
491
492 /// Unlike livein_begin, this method does not check that the liveness
493 /// information is accurate. Still for debug purposes it may be useful
494 /// to have iterators that won't assert if the liveness information
495 /// is not current.
496 livein_iterator livein_begin_dbg() const { return LiveIns.begin(); }
499 }
500
502 livein_iterator livein_end() const { return LiveIns.end(); }
503 bool livein_empty() const { return LiveIns.empty(); }
506 }
507
508 /// Remove entry from the livein set and return iterator to the next.
510
511 const std::vector<RegisterMaskPair> &getLiveIns() const { return LiveIns; }
512
514 public:
515 using iterator_category = std::input_iterator_tag;
516 using difference_type = std::ptrdiff_t;
518 using pointer = const RegisterMaskPair *;
520
522 MCPhysReg ExceptionSelector, bool End)
523 : ExceptionPointer(ExceptionPointer),
524 ExceptionSelector(ExceptionSelector), BlockI(MBB.succ_begin()),
525 BlockEnd(MBB.succ_end()) {
526 if (End)
527 BlockI = BlockEnd;
528 else if (BlockI != BlockEnd) {
529 LiveRegI = (*BlockI)->livein_begin();
530 if (!advanceToValidPosition())
531 return;
532 if (LiveRegI->PhysReg == ExceptionPointer ||
533 LiveRegI->PhysReg == ExceptionSelector)
534 ++(*this);
535 }
536 }
537
539 do {
540 ++LiveRegI;
541 if (!advanceToValidPosition())
542 return *this;
543 } while ((*BlockI)->isEHPad() &&
544 (LiveRegI->PhysReg == ExceptionPointer ||
545 LiveRegI->PhysReg == ExceptionSelector));
546 return *this;
547 }
548
550 liveout_iterator Tmp = *this;
551 ++(*this);
552 return Tmp;
553 }
554
556 return *LiveRegI;
557 }
558
560 return &*LiveRegI;
561 }
562
563 bool operator==(const liveout_iterator &RHS) const {
564 if (BlockI != BlockEnd)
565 return BlockI == RHS.BlockI && LiveRegI == RHS.LiveRegI;
566 return RHS.BlockI == BlockEnd;
567 }
568
569 bool operator!=(const liveout_iterator &RHS) const {
570 return !(*this == RHS);
571 }
572 private:
573 bool advanceToValidPosition() {
574 if (LiveRegI != (*BlockI)->livein_end())
575 return true;
576
577 do {
578 ++BlockI;
579 } while (BlockI != BlockEnd && (*BlockI)->livein_empty());
580 if (BlockI == BlockEnd)
581 return false;
582
583 LiveRegI = (*BlockI)->livein_begin();
584 return true;
585 }
586
587 MCPhysReg ExceptionPointer, ExceptionSelector;
588 const_succ_iterator BlockI;
589 const_succ_iterator BlockEnd;
590 livein_iterator LiveRegI;
591 };
592
593 /// Iterator scanning successor basic blocks' liveins to determine the
594 /// registers potentially live at the end of this block. There may be
595 /// duplicates or overlapping registers in the list returned.
596 liveout_iterator liveout_begin() const;
598 return liveout_iterator(*this, 0, 0, true);
599 }
602 }
603
604 /// Get the clobber mask for the start of this basic block. Funclets use this
605 /// to prevent register allocation across funclet transitions.
607
608 /// Get the clobber mask for the end of the basic block.
609 /// \see getBeginClobberMask()
611
612 /// Return alignment of the basic block.
613 Align getAlignment() const { return Alignment; }
614
615 /// Set alignment of the basic block.
616 void setAlignment(Align A) { Alignment = A; }
617
618 void setAlignment(Align A, unsigned MaxBytes) {
620 setMaxBytesForAlignment(MaxBytes);
621 }
622
623 /// Return the maximum amount of padding allowed for aligning the basic block.
624 unsigned getMaxBytesForAlignment() const { return MaxBytesForAlignment; }
625
626 /// Set the maximum amount of padding allowed for aligning the basic block
627 void setMaxBytesForAlignment(unsigned MaxBytes) {
628 MaxBytesForAlignment = MaxBytes;
629 }
630
631 /// Returns true if the block is a landing pad. That is this basic block is
632 /// entered via an exception handler.
633 bool isEHPad() const { return IsEHPad; }
634
635 /// Indicates the block is a landing pad. That is this basic block is entered
636 /// via an exception handler.
637 void setIsEHPad(bool V = true) { IsEHPad = V; }
638
639 bool hasEHPadSuccessor() const;
640
641 /// Returns true if this is the entry block of the function.
642 bool isEntryBlock() const;
643
644 /// Returns true if this is the entry block of an EH scope, i.e., the block
645 /// that used to have a catchpad or cleanuppad instruction in the LLVM IR.
646 bool isEHScopeEntry() const { return IsEHScopeEntry; }
647
648 /// Indicates if this is the entry block of an EH scope, i.e., the block that
649 /// that used to have a catchpad or cleanuppad instruction in the LLVM IR.
650 void setIsEHScopeEntry(bool V = true) { IsEHScopeEntry = V; }
651
652 /// Returns true if this is a target block of a catchret.
653 bool isEHCatchretTarget() const { return IsEHCatchretTarget; }
654
655 /// Indicates if this is a target block of a catchret.
656 void setIsEHCatchretTarget(bool V = true) { IsEHCatchretTarget = V; }
657
658 /// Returns true if this is the entry block of an EH funclet.
659 bool isEHFuncletEntry() const { return IsEHFuncletEntry; }
660
661 /// Indicates if this is the entry block of an EH funclet.
662 void setIsEHFuncletEntry(bool V = true) { IsEHFuncletEntry = V; }
663
664 /// Returns true if this is the entry block of a cleanup funclet.
665 bool isCleanupFuncletEntry() const { return IsCleanupFuncletEntry; }
666
667 /// Indicates if this is the entry block of a cleanup funclet.
668 void setIsCleanupFuncletEntry(bool V = true) { IsCleanupFuncletEntry = V; }
669
670 /// Returns true if this block begins any section.
671 bool isBeginSection() const { return IsBeginSection; }
672
673 /// Returns true if this block ends any section.
674 bool isEndSection() const { return IsEndSection; }
675
676 void setIsBeginSection(bool V = true) { IsBeginSection = V; }
677
678 void setIsEndSection(bool V = true) { IsEndSection = V; }
679
680 std::optional<UniqueBBID> getBBID() const { return BBID; }
681
682 /// Returns the section ID of this basic block.
683 MBBSectionID getSectionID() const { return SectionID; }
684
685 /// Sets the fixed BBID of this basic block.
686 void setBBID(const UniqueBBID &V) {
687 assert(!BBID.has_value() && "Cannot change BBID.");
688 BBID = V;
689 }
690
691 /// Sets the section ID for this basic block.
692 void setSectionID(MBBSectionID V) { SectionID = V; }
693
694 /// Returns the MCSymbol marking the end of this basic block.
695 MCSymbol *getEndSymbol() const;
696
697 /// Returns true if this block may have an INLINEASM_BR (overestimate, by
698 /// checking if any of the successors are indirect targets of any inlineasm_br
699 /// in the function).
700 bool mayHaveInlineAsmBr() const;
701
702 /// Returns true if this is the indirect dest of an INLINEASM_BR.
704 return IsInlineAsmBrIndirectTarget;
705 }
706
707 /// Indicates if this is the indirect dest of an INLINEASM_BR.
708 void setIsInlineAsmBrIndirectTarget(bool V = true) {
709 IsInlineAsmBrIndirectTarget = V;
710 }
711
712 /// Returns true if it is legal to hoist instructions into this block.
713 bool isLegalToHoistInto() const;
714
715 // Code Layout methods.
716
717 /// Move 'this' block before or after the specified block. This only moves
718 /// the block, it does not modify the CFG or adjust potential fall-throughs at
719 /// the end of the block.
720 void moveBefore(MachineBasicBlock *NewAfter);
721 void moveAfter(MachineBasicBlock *NewBefore);
722
723 /// Returns true if this and MBB belong to the same section.
724 bool sameSection(const MachineBasicBlock *MBB) const {
725 return getSectionID() == MBB->getSectionID();
726 }
727
728 /// Update the terminator instructions in block to account for changes to
729 /// block layout which may have been made. PreviousLayoutSuccessor should be
730 /// set to the block which may have been used as fallthrough before the block
731 /// layout was modified. If the block previously fell through to that block,
732 /// it may now need a branch. If it previously branched to another block, it
733 /// may now be able to fallthrough to the current layout successor.
734 void updateTerminator(MachineBasicBlock *PreviousLayoutSuccessor);
735
736 // Machine-CFG mutators
737
738 /// Add Succ as a successor of this MachineBasicBlock. The Predecessors list
739 /// of Succ is automatically updated. PROB parameter is stored in
740 /// Probabilities list. The default probability is set as unknown. Mixing
741 /// known and unknown probabilities in successor list is not allowed. When all
742 /// successors have unknown probabilities, 1 / N is returned as the
743 /// probability for each successor, where N is the number of successors.
744 ///
745 /// Note that duplicate Machine CFG edges are not allowed.
748
749 /// Add Succ as a successor of this MachineBasicBlock. The Predecessors list
750 /// of Succ is automatically updated. The probability is not provided because
751 /// BPI is not available (e.g. -O0 is used), in which case edge probabilities
752 /// won't be used. Using this interface can save some space.
754
755 /// Set successor probability of a given iterator.
757
758 /// Normalize probabilities of all successors so that the sum of them becomes
759 /// one. This is usually done when the current update on this MBB is done, and
760 /// the sum of its successors' probabilities is not guaranteed to be one. The
761 /// user is responsible for the correct use of this function.
762 /// MBB::removeSuccessor() has an option to do this automatically.
764 BranchProbability::normalizeProbabilities(Probs.begin(), Probs.end());
765 }
766
767 /// Validate successors' probabilities and check if the sum of them is
768 /// approximate one. This only works in DEBUG mode.
769 void validateSuccProbs() const;
770
771 /// Remove successor from the successors list of this MachineBasicBlock. The
772 /// Predecessors list of Succ is automatically updated.
773 /// If NormalizeSuccProbs is true, then normalize successors' probabilities
774 /// after the successor is removed.
776 bool NormalizeSuccProbs = false);
777
778 /// Remove specified successor from the successors list of this
779 /// MachineBasicBlock. The Predecessors list of Succ is automatically updated.
780 /// If NormalizeSuccProbs is true, then normalize successors' probabilities
781 /// after the successor is removed.
782 /// Return the iterator to the element after the one removed.
784 bool NormalizeSuccProbs = false);
785
786 /// Replace successor OLD with NEW and update probability info.
788
789 /// Copy a successor (and any probability info) from original block to this
790 /// block's. Uses an iterator into the original blocks successors.
791 ///
792 /// This is useful when doing a partial clone of successors. Afterward, the
793 /// probabilities may need to be normalized.
795
796 /// Split the old successor into old plus new and updates the probability
797 /// info.
799 bool NormalizeSuccProbs = false);
800
801 /// Transfers all the successors from MBB to this machine basic block (i.e.,
802 /// copies all the successors FromMBB and remove all the successors from
803 /// FromMBB).
805
806 /// Transfers all the successors, as in transferSuccessors, and update PHI
807 /// operands in the successor blocks which refer to FromMBB to refer to this.
809
810 /// Return true if any of the successors have probabilities attached to them.
811 bool hasSuccessorProbabilities() const { return !Probs.empty(); }
812
813 /// Return true if the specified MBB is a predecessor of this block.
814 bool isPredecessor(const MachineBasicBlock *MBB) const;
815
816 /// Return true if the specified MBB is a successor of this block.
817 bool isSuccessor(const MachineBasicBlock *MBB) const;
818
819 /// Return true if the specified MBB will be emitted immediately after this
820 /// block, such that if this block exits by falling through, control will
821 /// transfer to the specified MBB. Note that MBB need not be a successor at
822 /// all, for example if this block ends with an unconditional branch to some
823 /// other block.
824 bool isLayoutSuccessor(const MachineBasicBlock *MBB) const;
825
826 /// Return the successor of this block if it has a single successor.
827 /// Otherwise return a null pointer.
828 ///
831 return const_cast<MachineBasicBlock *>(
832 static_cast<const MachineBasicBlock *>(this)->getSingleSuccessor());
833 }
834
835 /// Return the predecessor of this block if it has a single predecessor.
836 /// Otherwise return a null pointer.
837 ///
840 return const_cast<MachineBasicBlock *>(
841 static_cast<const MachineBasicBlock *>(this)->getSinglePredecessor());
842 }
843
844 /// Return the fallthrough block if the block can implicitly
845 /// transfer control to the block after it by falling off the end of
846 /// it. If an explicit branch to the fallthrough block is not allowed,
847 /// set JumpToFallThrough to be false. Non-null return is a conservative
848 /// answer.
849 MachineBasicBlock *getFallThrough(bool JumpToFallThrough = true);
850
851 /// Return the fallthrough block if the block can implicitly
852 /// transfer control to it's successor, whether by a branch or
853 /// a fallthrough. Non-null return is a conservative answer.
855
856 /// Return true if the block can implicitly transfer control to the
857 /// block after it by falling off the end of it. This should return
858 /// false if it can reach the block after it, but it uses an
859 /// explicit branch to do so (e.g., a table jump). True is a
860 /// conservative answer.
861 bool canFallThrough();
862
863 /// Returns a pointer to the first instruction in this block that is not a
864 /// PHINode instruction. When adding instructions to the beginning of the
865 /// basic block, they should be added before the returned value, not before
866 /// the first instruction, which might be PHI.
867 /// Returns end() is there's no non-PHI instruction.
870 return const_cast<MachineBasicBlock *>(this)->getFirstNonPHI();
871 }
872
873 /// Return the first instruction in MBB after I that is not a PHI or a label.
874 /// This is the correct point to insert lowered copies at the beginning of a
875 /// basic block that must be before any debugging information.
877
878 /// Return the first instruction in MBB after I that is not a PHI, label or
879 /// debug. This is the correct point to insert copies at the beginning of a
880 /// basic block. \p Reg is the register being used by a spill or defined for a
881 /// restore/split during register allocation.
883 bool SkipPseudoOp = true);
884
885 /// Returns an iterator to the first terminator instruction of this basic
886 /// block. If a terminator does not exist, it returns end().
889 return const_cast<MachineBasicBlock *>(this)->getFirstTerminator();
890 }
891
892 /// Same getFirstTerminator but it ignores bundles and return an
893 /// instr_iterator instead.
895
896 /// Finds the first terminator in a block by scanning forward. This can handle
897 /// cases in GlobalISel where there may be non-terminator instructions between
898 /// terminators, for which getFirstTerminator() will not work correctly.
900
901 /// Returns an iterator to the first non-debug instruction in the basic block,
902 /// or end(). Skip any pseudo probe operation if \c SkipPseudoOp is true.
903 /// Pseudo probes are like debug instructions which do not turn into real
904 /// machine code. We try to use the function to skip both debug instructions
905 /// and pseudo probe operations to avoid API proliferation. This should work
906 /// most of the time when considering optimizing the rest of code in the
907 /// block, except for certain cases where pseudo probes are designed to block
908 /// the optimizations. For example, code merge like optimizations are supposed
909 /// to be blocked by pseudo probes for better AutoFDO profile quality.
910 /// Therefore, they should be considered as a valid instruction when this
911 /// function is called in a context of such optimizations. On the other hand,
912 /// \c SkipPseudoOp should be true when it's used in optimizations that
913 /// unlikely hurt profile quality, e.g., without block merging. The default
914 /// value of \c SkipPseudoOp is set to true to maximize code quality in
915 /// general, with an explict false value passed in in a few places like branch
916 /// folding and if-conversion to favor profile quality.
917 iterator getFirstNonDebugInstr(bool SkipPseudoOp = true);
918 const_iterator getFirstNonDebugInstr(bool SkipPseudoOp = true) const {
919 return const_cast<MachineBasicBlock *>(this)->getFirstNonDebugInstr(
920 SkipPseudoOp);
921 }
922
923 /// Returns an iterator to the last non-debug instruction in the basic block,
924 /// or end(). Skip any pseudo operation if \c SkipPseudoOp is true.
925 /// Pseudo probes are like debug instructions which do not turn into real
926 /// machine code. We try to use the function to skip both debug instructions
927 /// and pseudo probe operations to avoid API proliferation. This should work
928 /// most of the time when considering optimizing the rest of code in the
929 /// block, except for certain cases where pseudo probes are designed to block
930 /// the optimizations. For example, code merge like optimizations are supposed
931 /// to be blocked by pseudo probes for better AutoFDO profile quality.
932 /// Therefore, they should be considered as a valid instruction when this
933 /// function is called in a context of such optimizations. On the other hand,
934 /// \c SkipPseudoOp should be true when it's used in optimizations that
935 /// unlikely hurt profile quality, e.g., without block merging. The default
936 /// value of \c SkipPseudoOp is set to true to maximize code quality in
937 /// general, with an explict false value passed in in a few places like branch
938 /// folding and if-conversion to favor profile quality.
939 iterator getLastNonDebugInstr(bool SkipPseudoOp = true);
940 const_iterator getLastNonDebugInstr(bool SkipPseudoOp = true) const {
941 return const_cast<MachineBasicBlock *>(this)->getLastNonDebugInstr(
942 SkipPseudoOp);
943 }
944
945 /// Convenience function that returns true if the block ends in a return
946 /// instruction.
947 bool isReturnBlock() const {
948 return !empty() && back().isReturn();
949 }
950
951 /// Convenience function that returns true if the bock ends in a EH scope
952 /// return instruction.
953 bool isEHScopeReturnBlock() const {
954 return !empty() && back().isEHScopeReturn();
955 }
956
957 /// Split a basic block into 2 pieces at \p SplitPoint. A new block will be
958 /// inserted after this block, and all instructions after \p SplitInst moved
959 /// to it (\p SplitInst will be in the original block). If \p LIS is provided,
960 /// LiveIntervals will be appropriately updated. \return the newly inserted
961 /// block.
962 ///
963 /// If \p UpdateLiveIns is true, this will ensure the live ins list is
964 /// accurate, including for physreg uses/defs in the original block.
965 MachineBasicBlock *splitAt(MachineInstr &SplitInst, bool UpdateLiveIns = true,
966 LiveIntervals *LIS = nullptr);
967
968 /// Split the critical edge from this block to the given successor block, and
969 /// return the newly created block, or null if splitting is not possible.
970 ///
971 /// This function updates LiveVariables, MachineDominatorTree, and
972 /// MachineLoopInfo, as applicable.
975 std::vector<SparseBitVector<>> *LiveInSets = nullptr) {
976 return SplitCriticalEdge(Succ, &P, nullptr, LiveInSets);
977 }
978
982 std::vector<SparseBitVector<>> *LiveInSets = nullptr) {
983 return SplitCriticalEdge(Succ, nullptr, &MFAM, LiveInSets);
984 }
985
986 /// Check if the edge between this block and the given successor \p
987 /// Succ, can be split. If this returns true a subsequent call to
988 /// SplitCriticalEdge is guaranteed to return a valid basic block if
989 /// no changes occurred in the meantime.
990 bool canSplitCriticalEdge(const MachineBasicBlock *Succ) const;
991
992 void pop_front() { Insts.pop_front(); }
993 void pop_back() { Insts.pop_back(); }
994 void push_back(MachineInstr *MI) { Insts.push_back(MI); }
995
996 /// Insert MI into the instruction list before I, possibly inside a bundle.
997 ///
998 /// If the insertion point is inside a bundle, MI will be added to the bundle,
999 /// otherwise MI will not be added to any bundle. That means this function
1000 /// alone can't be used to prepend or append instructions to bundles. See
1001 /// MIBundleBuilder::insert() for a more reliable way of doing that.
1003
1004 /// Insert a range of instructions into the instruction list before I.
1005 template<typename IT>
1006 void insert(iterator I, IT S, IT E) {
1007 assert((I == end() || I->getParent() == this) &&
1008 "iterator points outside of basic block");
1009 Insts.insert(I.getInstrIterator(), S, E);
1010 }
1011
1012 /// Insert MI into the instruction list before I.
1014 assert((I == end() || I->getParent() == this) &&
1015 "iterator points outside of basic block");
1016 assert(!MI->isBundledWithPred() && !MI->isBundledWithSucc() &&
1017 "Cannot insert instruction with bundle flags");
1018 return Insts.insert(I.getInstrIterator(), MI);
1019 }
1020
1021 /// Insert MI into the instruction list after I.
1023 assert((I == end() || I->getParent() == this) &&
1024 "iterator points outside of basic block");
1025 assert(!MI->isBundledWithPred() && !MI->isBundledWithSucc() &&
1026 "Cannot insert instruction with bundle flags");
1027 return Insts.insertAfter(I.getInstrIterator(), MI);
1028 }
1029
1030 /// If I is bundled then insert MI into the instruction list after the end of
1031 /// the bundle, otherwise insert MI immediately after I.
1033 assert((I == instr_end() || I->getParent() == this) &&
1034 "iterator points outside of basic block");
1035 assert(!MI->isBundledWithPred() && !MI->isBundledWithSucc() &&
1036 "Cannot insert instruction with bundle flags");
1037 while (I->isBundledWithSucc())
1038 ++I;
1039 return Insts.insertAfter(I, MI);
1040 }
1041
1042 /// Remove an instruction from the instruction list and delete it.
1043 ///
1044 /// If the instruction is part of a bundle, the other instructions in the
1045 /// bundle will still be bundled after removing the single instruction.
1047
1048 /// Remove an instruction from the instruction list and delete it.
1049 ///
1050 /// If the instruction is part of a bundle, the other instructions in the
1051 /// bundle will still be bundled after removing the single instruction.
1053 return erase(instr_iterator(I));
1054 }
1055
1056 /// Remove a range of instructions from the instruction list and delete them.
1058 return Insts.erase(I.getInstrIterator(), E.getInstrIterator());
1059 }
1060
1061 /// Remove an instruction or bundle from the instruction list and delete it.
1062 ///
1063 /// If I points to a bundle of instructions, they are all erased.
1065 return erase(I, std::next(I));
1066 }
1067
1068 /// Remove an instruction from the instruction list and delete it.
1069 ///
1070 /// If I is the head of a bundle of instructions, the whole bundle will be
1071 /// erased.
1073 return erase(iterator(I));
1074 }
1075
1076 /// Remove the unbundled instruction from the instruction list without
1077 /// deleting it.
1078 ///
1079 /// This function can not be used to remove bundled instructions, use
1080 /// remove_instr to remove individual instructions from a bundle.
1082 assert(!I->isBundled() && "Cannot remove bundled instructions");
1083 return Insts.remove(instr_iterator(I));
1084 }
1085
1086 /// Remove the possibly bundled instruction from the instruction list
1087 /// without deleting it.
1088 ///
1089 /// If the instruction is part of a bundle, the other instructions in the
1090 /// bundle will still be bundled after removing the single instruction.
1092
1093 void clear() {
1094 Insts.clear();
1095 }
1096
1097 /// Take an instruction from MBB 'Other' at the position From, and insert it
1098 /// into this MBB right before 'Where'.
1099 ///
1100 /// If From points to a bundle of instructions, the whole bundle is moved.
1102 // The range splice() doesn't allow noop moves, but this one does.
1103 if (Where != From)
1104 splice(Where, Other, From, std::next(From));
1105 }
1106
1107 /// Take a block of instructions from MBB 'Other' in the range [From, To),
1108 /// and insert them into this MBB right before 'Where'.
1109 ///
1110 /// The instruction at 'Where' must not be included in the range of
1111 /// instructions to move.
1113 iterator From, iterator To) {
1114 Insts.splice(Where.getInstrIterator(), Other->Insts,
1115 From.getInstrIterator(), To.getInstrIterator());
1116 }
1117
1118 /// This method unlinks 'this' from the containing function, and returns it,
1119 /// but does not delete it.
1121
1122 /// This method unlinks 'this' from the containing function and deletes it.
1123 void eraseFromParent();
1124
1125 /// Given a machine basic block that branched to 'Old', change the code and
1126 /// CFG so that it branches to 'New' instead.
1128
1129 /// Update all phi nodes in this basic block to refer to basic block \p New
1130 /// instead of basic block \p Old.
1132
1133 /// Find the next valid DebugLoc starting at MBBI, skipping any debug
1134 /// instructions. Return UnknownLoc if there is none.
1137 return findDebugLoc(MBBI.getInstrIterator());
1138 }
1139
1140 /// Has exact same behavior as @ref findDebugLoc (it also searches towards the
1141 /// end of this MBB) except that this function takes a reverse iterator to
1142 /// identify the starting MI.
1145 return rfindDebugLoc(MBBI.getInstrIterator());
1146 }
1147
1148 /// Find the previous valid DebugLoc preceding MBBI, skipping any debug
1149 /// instructions. It is possible to find the last DebugLoc in the MBB using
1150 /// findPrevDebugLoc(instr_end()). Return UnknownLoc if there is none.
1153 return findPrevDebugLoc(MBBI.getInstrIterator());
1154 }
1155
1156 /// Has exact same behavior as @ref findPrevDebugLoc (it also searches towards
1157 /// the beginning of this MBB) except that this function takes reverse
1158 /// iterator to identify the starting MI. A minor difference compared to
1159 /// findPrevDebugLoc is that we can't start scanning at "instr_end".
1162 return rfindPrevDebugLoc(MBBI.getInstrIterator());
1163 }
1164
1165 /// Find and return the merged DebugLoc of the branch instructions of the
1166 /// block. Return UnknownLoc if there is none.
1168
1169 /// Possible outcome of a register liveness query to computeRegisterLiveness()
1171 LQR_Live, ///< Register is known to be (at least partially) live.
1172 LQR_Dead, ///< Register is known to be fully dead.
1173 LQR_Unknown ///< Register liveness not decidable from local neighborhood.
1175
1176 /// Return whether (physical) register \p Reg has been defined and not
1177 /// killed as of just before \p Before.
1178 ///
1179 /// Search is localised to a neighborhood of \p Neighborhood instructions
1180 /// before (searching for defs or kills) and \p Neighborhood instructions
1181 /// after (searching just for defs) \p Before.
1182 ///
1183 /// \p Reg must be a physical register.
1187 unsigned Neighborhood = 10) const;
1188
1189 // Debugging methods.
1190 void dump() const;
1191 void print(raw_ostream &OS, const SlotIndexes * = nullptr,
1192 bool IsStandalone = true) const;
1194 const SlotIndexes * = nullptr, bool IsStandalone = true) const;
1195
1197 PrintNameIr = (1 << 0), ///< Add IR name where available
1198 PrintNameAttributes = (1 << 1), ///< Print attributes
1199 };
1200
1201 void printName(raw_ostream &os, unsigned printNameFlags = PrintNameIr,
1202 ModuleSlotTracker *moduleSlotTracker = nullptr) const;
1203
1204 // Printing method used by LoopInfo.
1205 void printAsOperand(raw_ostream &OS, bool PrintType = true) const;
1206
1207 /// MachineBasicBlocks are uniquely numbered at the function level, unless
1208 /// they're not in a MachineFunction yet, in which case this will return -1.
1209 int getNumber() const { return Number; }
1210 void setNumber(int N) { Number = N; }
1211
1212 /// Return the call frame size on entry to this basic block.
1213 unsigned getCallFrameSize() const { return CallFrameSize; }
1214 /// Set the call frame size on entry to this basic block.
1215 void setCallFrameSize(unsigned N) { CallFrameSize = N; }
1216
1217 /// Return the MCSymbol for this basic block.
1218 MCSymbol *getSymbol() const;
1219
1220 /// Return the EHCatchret Symbol for this basic block.
1222
1223 std::optional<uint64_t> getIrrLoopHeaderWeight() const {
1224 return IrrLoopHeaderWeight;
1225 }
1226
1228 IrrLoopHeaderWeight = Weight;
1229 }
1230
1231 /// Return probability of the edge from this block to MBB. This method should
1232 /// NOT be called directly, but by using getEdgeProbability method from
1233 /// MachineBranchProbabilityInfo class.
1235
1236private:
1237 /// Return probability iterator corresponding to the I successor iterator.
1238 probability_iterator getProbabilityIterator(succ_iterator I);
1239 const_probability_iterator
1240 getProbabilityIterator(const_succ_iterator I) const;
1241
1243 friend class MIPrinter;
1244
1245 // Methods used to maintain doubly linked list of blocks...
1247
1248 // Machine-CFG mutators
1249
1250 /// Add Pred as a predecessor of this MachineBasicBlock. Don't do this
1251 /// unless you know what you're doing, because it doesn't update Pred's
1252 /// successors list. Use Pred->addSuccessor instead.
1253 void addPredecessor(MachineBasicBlock *Pred);
1254
1255 /// Remove Pred as a predecessor of this MachineBasicBlock. Don't do this
1256 /// unless you know what you're doing, because it doesn't update Pred's
1257 /// successors list. Use Pred->removeSuccessor instead.
1258 void removePredecessor(MachineBasicBlock *Pred);
1259
1260 // Helper method for new pass manager migration.
1264 std::vector<SparseBitVector<>> *LiveInSets);
1265};
1266
1268
1269/// Prints a machine basic block reference.
1270///
1271/// The format is:
1272/// %bb.5 - a machine basic block with MBB.getNumber() == 5.
1273///
1274/// Usage: OS << printMBBReference(MBB) << '\n';
1276
1277// This is useful when building IndexedMaps keyed on basic block pointers.
1280 unsigned operator()(const MachineBasicBlock *MBB) const {
1281 return MBB->getNumber();
1282 }
1283};
1284
1285//===--------------------------------------------------------------------===//
1286// GraphTraits specializations for machine basic block graphs (machine-CFGs)
1287//===--------------------------------------------------------------------===//
1288
1289// Provide specializations of GraphTraits to be able to treat a
1290// MachineFunction as a graph of MachineBasicBlocks.
1291//
1292
1293template <> struct GraphTraits<MachineBasicBlock *> {
1296
1297 static NodeRef getEntryNode(MachineBasicBlock *BB) { return BB; }
1298 static ChildIteratorType child_begin(NodeRef N) { return N->succ_begin(); }
1299 static ChildIteratorType child_end(NodeRef N) { return N->succ_end(); }
1300
1301 static unsigned getNumber(MachineBasicBlock *BB) {
1302 assert(BB->getNumber() >= 0 && "negative block number");
1303 return BB->getNumber();
1304 }
1305};
1306
1307static_assert(GraphHasNodeNumbers<MachineBasicBlock *>,
1308 "GraphTraits getNumber() not detected");
1309
1310template <> struct GraphTraits<const MachineBasicBlock *> {
1313
1314 static NodeRef getEntryNode(const MachineBasicBlock *BB) { return BB; }
1315 static ChildIteratorType child_begin(NodeRef N) { return N->succ_begin(); }
1316 static ChildIteratorType child_end(NodeRef N) { return N->succ_end(); }
1317
1318 static unsigned getNumber(const MachineBasicBlock *BB) {
1319 assert(BB->getNumber() >= 0 && "negative block number");
1320 return BB->getNumber();
1321 }
1322};
1323
1324static_assert(GraphHasNodeNumbers<const MachineBasicBlock *>,
1325 "GraphTraits getNumber() not detected");
1326
1327// Provide specializations of GraphTraits to be able to treat a
1328// MachineFunction as a graph of MachineBasicBlocks and to walk it
1329// in inverse order. Inverse order for a function is considered
1330// to be when traversing the predecessor edges of a MBB
1331// instead of the successor edges.
1332//
1336
1338 return G.Graph;
1339 }
1340
1341 static ChildIteratorType child_begin(NodeRef N) { return N->pred_begin(); }
1342 static ChildIteratorType child_end(NodeRef N) { return N->pred_end(); }
1343
1344 static unsigned getNumber(MachineBasicBlock *BB) {
1345 assert(BB->getNumber() >= 0 && "negative block number");
1346 return BB->getNumber();
1347 }
1348};
1349
1350static_assert(GraphHasNodeNumbers<Inverse<MachineBasicBlock *>>,
1351 "GraphTraits getNumber() not detected");
1352
1356
1358 return G.Graph;
1359 }
1360
1361 static ChildIteratorType child_begin(NodeRef N) { return N->pred_begin(); }
1362 static ChildIteratorType child_end(NodeRef N) { return N->pred_end(); }
1363
1364 static unsigned getNumber(const MachineBasicBlock *BB) {
1365 assert(BB->getNumber() >= 0 && "negative block number");
1366 return BB->getNumber();
1367 }
1368};
1369
1370static_assert(GraphHasNodeNumbers<Inverse<const MachineBasicBlock *>>,
1371 "GraphTraits getNumber() not detected");
1372
1373// These accessors are handy for sharing templated code between IR and MIR.
1374inline auto successors(const MachineBasicBlock *BB) { return BB->successors(); }
1375inline auto predecessors(const MachineBasicBlock *BB) {
1376 return BB->predecessors();
1377}
1378
1379/// MachineInstrSpan provides an interface to get an iteration range
1380/// containing the instruction it was initialized with, along with all
1381/// those instructions inserted prior to or following that instruction
1382/// at some point after the MachineInstrSpan is constructed.
1384 MachineBasicBlock &MBB;
1386
1387public:
1389 : MBB(*BB), I(I), B(I == MBB.begin() ? MBB.end() : std::prev(I)),
1390 E(std::next(I)) {
1391 assert(I == BB->end() || I->getParent() == BB);
1392 }
1393
1395 return B == MBB.end() ? MBB.begin() : std::next(B);
1396 }
1398 bool empty() { return begin() == end(); }
1399
1401};
1402
1403/// Increment \p It until it points to a non-debug instruction or to \p End
1404/// and return the resulting iterator. This function should only be used
1405/// MachineBasicBlock::{iterator, const_iterator, instr_iterator,
1406/// const_instr_iterator} and the respective reverse iterators.
1407template <typename IterT>
1408inline IterT skipDebugInstructionsForward(IterT It, IterT End,
1409 bool SkipPseudoOp = true) {
1410 while (It != End &&
1411 (It->isDebugInstr() || (SkipPseudoOp && It->isPseudoProbe())))
1412 ++It;
1413 return It;
1414}
1415
1416/// Decrement \p It until it points to a non-debug instruction or to \p Begin
1417/// and return the resulting iterator. This function should only be used
1418/// MachineBasicBlock::{iterator, const_iterator, instr_iterator,
1419/// const_instr_iterator} and the respective reverse iterators.
1420template <class IterT>
1421inline IterT skipDebugInstructionsBackward(IterT It, IterT Begin,
1422 bool SkipPseudoOp = true) {
1423 while (It != Begin &&
1424 (It->isDebugInstr() || (SkipPseudoOp && It->isPseudoProbe())))
1425 --It;
1426 return It;
1427}
1428
1429/// Increment \p It, then continue incrementing it while it points to a debug
1430/// instruction. A replacement for std::next.
1431template <typename IterT>
1432inline IterT next_nodbg(IterT It, IterT End, bool SkipPseudoOp = true) {
1433 return skipDebugInstructionsForward(std::next(It), End, SkipPseudoOp);
1434}
1435
1436/// Decrement \p It, then continue decrementing it while it points to a debug
1437/// instruction. A replacement for std::prev.
1438template <typename IterT>
1439inline IterT prev_nodbg(IterT It, IterT Begin, bool SkipPseudoOp = true) {
1440 return skipDebugInstructionsBackward(std::prev(It), Begin, SkipPseudoOp);
1441}
1442
1443/// Construct a range iterator which begins at \p It and moves forwards until
1444/// \p End is reached, skipping any debug instructions.
1445template <typename IterT>
1446inline auto instructionsWithoutDebug(IterT It, IterT End,
1447 bool SkipPseudoOp = true) {
1448 return make_filter_range(make_range(It, End), [=](const MachineInstr &MI) {
1449 return !MI.isDebugInstr() && !(SkipPseudoOp && MI.isPseudoProbe());
1450 });
1451}
1452
1453} // end namespace llvm
1454
1455#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")
This file defines DenseMapInfo traits for DenseMap.
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
Value * LHS
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:253
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:142
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
unsigned pred_size() const
void transferSuccessorsAndUpdatePHIs(MachineBasicBlock *FromMBB)
Transfers all the successors, as in transferSuccessors, and update PHI operands in the successor bloc...
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.
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
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 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 ...
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 * 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
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.
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.
MachineBasicBlock * SplitCriticalEdge(MachineBasicBlock *Succ, MachineFunctionAnalysisManager &MFAM, std::vector< SparseBitVector<> > *LiveInSets=nullptr)
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.
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...
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...
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
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:297
bool empty() const
Definition: SmallVector.h:95
size_t size() const
Definition: SmallVector.h:92
typename SuperClass::const_iterator const_iterator
Definition: SmallVector.h:592
typename SuperClass::iterator iterator
Definition: SmallVector.h:591
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: SmallVector.h:268
std::reverse_iterator< iterator > reverse_iterator
Definition: SmallVector.h:269
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1210
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
unsigned combineHashValue(unsigned a, unsigned b)
Simplistic combination of 32-bit hash values into 32-bit hash values.
Definition: DenseMapInfo.h:39
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 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...
Definition: DenseMapInfo.h:52
static NodeRef getEntryNode(Inverse< MachineBasicBlock * > G)
static unsigned getNumber(MachineBasicBlock *BB)
static ChildIteratorType child_begin(NodeRef N)
static unsigned getNumber(const MachineBasicBlock *BB)
static NodeRef getEntryNode(Inverse< const MachineBasicBlock * > G)
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()
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