LLVM 24.0.0git
LiveIntervals.h
Go to the documentation of this file.
1//===- LiveIntervals.h - Live Interval Analysis -----------------*- 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/// \file This file implements the LiveInterval analysis pass. Given some
10/// numbering of each the machine instructions (in this implemention depth-first
11/// order) an interval [i, j) is said to be a live interval for register v if
12/// there is no instruction with number j' > j such that v is live at j' and
13/// there is no instruction with number i' < i such that v is live at i'. In
14/// this implementation intervals can have holes, i.e. an interval might look
15/// like [1,20), [50,65), [1000,1001).
16//
17//===----------------------------------------------------------------------===//
18
19#ifndef LLVM_CODEGEN_LIVEINTERVALS_H
20#define LLVM_CODEGEN_LIVEINTERVALS_H
21
22#include "llvm/ADT/ArrayRef.h"
23#include "llvm/ADT/IndexedMap.h"
32#include "llvm/MC/LaneBitmask.h"
36#include <cassert>
37#include <cstdint>
38#include <utility>
39
40namespace llvm {
41
42class BitVector;
45class MachineFunction;
46class MachineInstr;
49class raw_ostream;
50class TargetInstrInfo;
51class VirtRegMap;
52
53class LiveIntervals {
56
57 MachineFunction *MF = nullptr;
58 MachineRegisterInfo *MRI = nullptr;
59 const TargetRegisterInfo *TRI = nullptr;
60 const TargetInstrInfo *TII = nullptr;
61 SlotIndexes *Indexes = nullptr;
62 MachineDominatorTree *DomTree = nullptr;
63 std::unique_ptr<LiveIntervalCalc> LICalc;
64
65 /// Special pool allocator for VNInfo's (LiveInterval val#).
66 VNInfo::Allocator VNInfoAllocator;
67
68 /// Live interval pointers for all the virtual registers.
70
71 /// Sorted list of instructions with register mask operands. Always use the
72 /// 'r' slot, RegMasks are normal clobbers, not early clobbers.
73 SmallVector<SlotIndex, 8> RegMaskSlots;
74
75 /// This vector is parallel to RegMaskSlots, it holds a pointer to the
76 /// corresponding register mask. This pointer can be recomputed as:
77 ///
78 /// MI = Indexes->getInstructionFromIndex(RegMaskSlot[N]);
79 /// unsigned OpNum = findRegMaskOperand(MI);
80 /// RegMaskBits[N] = MI->getOperand(OpNum).getRegMask();
81 ///
82 /// This is kept in a separate vector partly because some standard
83 /// libraries don't support lower_bound() with mixed objects, partly to
84 /// improve locality when searching in RegMaskSlots.
85 /// Also see the comment in LiveInterval::find().
87
88 /// For each basic block number, keep (begin, size) pairs indexing into the
89 /// RegMaskSlots and RegMaskBits arrays.
90 /// Note that basic block numbers may not be layout contiguous, that's why
91 /// we can't just keep track of the first register mask in each basic
92 /// block.
94
95 /// Keeps a live range set for each register unit to track fixed physreg
96 /// interference.
97 SmallVector<LiveRange *, 0> RegUnitRanges;
98
99 // Can only be created from pass manager.
100 LiveIntervals() = default;
101 LiveIntervals(MachineFunction &MF, SlotIndexes &SI, MachineDominatorTree &DT)
102 : Indexes(&SI), DomTree(&DT) {
103 analyze(MF);
104 }
105
106 LLVM_ABI void analyze(MachineFunction &MF);
107
108 LLVM_ABI void clear();
109
110public:
111 LiveIntervals(LiveIntervals &&) = default;
113
115 MachineFunctionAnalysisManager::Invalidator &Inv);
116
117 /// Calculate the spill weight to assign to a single instruction.
118 /// If \p PSI is provided the calculation is altered for optsize functions.
119 LLVM_ABI static float getSpillWeight(bool isDef, bool isUse,
120 const MachineBlockFrequencyInfo *MBFI,
121 const MachineInstr &MI,
122 ProfileSummaryInfo *PSI = nullptr);
123
124 /// Calculate the spill weight to assign to a single instruction.
125 /// If \p PSI is provided the calculation is altered for optsize functions.
126 LLVM_ABI static float getSpillWeight(bool isDef, bool isUse,
127 const MachineBlockFrequencyInfo *MBFI,
128 const MachineBasicBlock *MBB,
129 ProfileSummaryInfo *PSI = nullptr);
130
131 /// Variants taking a precomputed \p OptForSize rather than deriving it from a
132 /// ProfileSummaryInfo.
133 LLVM_ABI static float getSpillWeight(bool isDef, bool isUse,
134 const MachineBlockFrequencyInfo *MBFI,
135 const MachineInstr &MI, bool OptForSize);
136
137 LLVM_ABI static float getSpillWeight(bool isDef, bool isUse,
138 const MachineBlockFrequencyInfo *MBFI,
139 const MachineBasicBlock *MBB,
140 bool OptForSize);
141
143 if (hasInterval(Reg))
144 return *VirtRegIntervals[Reg.id()];
145
147 }
148
150 return const_cast<LiveIntervals *>(this)->getInterval(Reg);
151 }
152
154 return VirtRegIntervals.inBounds(Reg.id()) && VirtRegIntervals[Reg.id()];
155 }
156
157 /// Interval creation.
159 assert(!hasInterval(Reg) && "Interval already exists!");
160 VirtRegIntervals.grow(Reg.id());
161 auto &Interval = VirtRegIntervals[Reg.id()];
162 Interval = createInterval(Reg);
163 return *Interval;
164 }
165
168 computeVirtRegInterval(LI);
169 return LI;
170 }
171
174 NeedSplit = computeVirtRegInterval(LI);
175 return LI;
176 }
177
178 /// Return an existing interval for \p Reg.
179 /// If \p Reg has no interval then this creates a new empty one instead.
180 /// Note: does not trigger interval computation.
184
185 /// Interval removal.
187 auto &Interval = VirtRegIntervals[Reg];
188 delete Interval;
189 Interval = nullptr;
190 }
191
192 /// Given a register and an instruction, adds a live segment from that
193 /// instruction to the end of its MBB.
196
197 /// After removing some uses of a register, shrink its live range to just
198 /// the remaining uses. This method does not compute reaching defs for new
199 /// uses, and it doesn't remove dead defs.
200 /// Dead PHIDef values are marked as unused. New dead machine instructions
201 /// are added to the dead vector. Returns true if the interval may have been
202 /// separated into multiple connected components.
204 SmallVectorImpl<MachineInstr *> *dead = nullptr);
205
206 /// Specialized version of
207 /// shrinkToUses(LiveInterval *li, SmallVectorImpl<MachineInstr*> *dead)
208 /// that works on a subregister live range and only looks at uses matching
209 /// the lane mask of the subregister range.
210 /// This may leave the subrange empty which needs to be cleaned up with
211 /// LiveInterval::removeEmptySubranges() afterwards.
213
214 /// Extend the live range \p LR to reach all points in \p Indices. The
215 /// points in the \p Indices array must be jointly dominated by the union
216 /// of the existing defs in \p LR and points in \p Undefs.
217 ///
218 /// PHI-defs are added as needed to maintain SSA form.
219 ///
220 /// If a SlotIndex in \p Indices is the end index of a basic block, \p LR
221 /// will be extended to be live out of the basic block.
222 /// If a SlotIndex in \p Indices is jointy dominated only by points in
223 /// \p Undefs, the live range will not be extended to that point.
224 ///
225 /// See also LiveRangeCalc::extend().
227 ArrayRef<SlotIndex> Undefs);
228
230 extendToIndices(LR, Indices, /*Undefs=*/{});
231 }
232
233 /// If \p LR has a live value at \p Kill, prune its live range by removing
234 /// any liveness reachable from Kill. Add live range end points to
235 /// EndPoints such that extendToIndices(LI, EndPoints) will reconstruct the
236 /// value's live range.
237 ///
238 /// Calling pruneValue() and extendToIndices() can be used to reconstruct
239 /// SSA form after adding defs to a virtual register.
241 SmallVectorImpl<SlotIndex> *EndPoints);
242
243 /// This function should not be used. Its intent is to tell you that you are
244 /// doing something wrong if you call pruneValue directly on a
245 /// LiveInterval. Indeed, you are supposed to call pruneValue on the main
246 /// LiveRange and all the LiveRanges of the subranges if any.
247 [[maybe_unused]] void pruneValue(LiveInterval &, SlotIndex,
250 "Use pruneValue on the main LiveRange and on each subrange");
251 }
252
253 SlotIndexes *getSlotIndexes() const { return Indexes; }
254
255 /// Remove intervals for virtual registers no instruction refers to any
256 /// more. Their segments sit on erased indexes. Returns the number removed.
258
259 /// Returns true if the specified machine instr has been removed or was
260 /// never entered in the map.
261 bool isNotInMIMap(const MachineInstr &Instr) const {
262 return !Indexes->hasIndex(Instr);
263 }
264
265 /// Returns the base index of the given instruction.
267 return Indexes->getInstructionIndex(Instr);
268 }
269
270 /// Returns the instruction associated with the given index.
272 return Indexes->getInstructionFromIndex(index);
273 }
274
275 /// Return the first index in the given basic block.
277 return Indexes->getMBBStartIdx(mbb);
278 }
279
280 /// Return the last index in the given basic block.
282 return Indexes->getMBBEndIdx(mbb);
283 }
284
285 bool isLiveInToMBB(const LiveRange &LR, const MachineBasicBlock *mbb) const {
286 return LR.liveAt(getMBBStartIdx(mbb));
287 }
288
289 bool isLiveOutOfMBB(const LiveRange &LR, const MachineBasicBlock *mbb) const {
290 return LR.liveAt(getMBBEndIdx(mbb).getPrevSlot());
291 }
292
294 return Indexes->getMBBFromIndex(index);
295 }
296
297 /// Adds an empty block \p MBB to the SlotIndexes and regmask maps.
299 insertMBBInMapsImpl(MBB, /*AssumeRegMaskEmpty=*/true);
300 }
301
302 /// After the tail of \p Orig has been sliced into \p SplitBB, updates the
303 /// SlotIndexes and regmask maps and re-slices \p Orig's regmask table across
304 /// the two blocks.
306 insertMBBInMapsImpl(&SplitBB, /*AssumeRegMaskEmpty=*/false);
307 reassignRegMaskSlots(Orig, SplitBB);
308 }
309
311 return Indexes->insertMachineInstrInMaps(MI);
312 }
313
316 for (MachineBasicBlock::iterator I = B; I != E; ++I)
317 Indexes->insertMachineInstrInMaps(*I);
318 }
319
321 Indexes->removeMachineInstrFromMaps(MI);
322 }
323
325 return Indexes->replaceMachineInstrInMaps(MI, NewMI);
326 }
327
328 VNInfo::Allocator &getVNInfoAllocator() { return VNInfoAllocator; }
329
330 /// Implement the dump method.
331 LLVM_ABI void print(raw_ostream &O) const;
332 LLVM_ABI void dump() const;
333
334 // For legacy pass to recompute liveness.
336 clear();
337 analyze(MF);
338 }
339
340 MachineDominatorTree &getDomTree() { return *DomTree; }
341
342 /// If LI is confined to a single basic block, return a pointer to that
343 /// block. If LI is live in to or out of any block, return NULL.
345
346 /// Returns true if VNI is killed by any PHI-def values in LI.
347 /// This may conservatively return true to avoid expensive computations.
348 LLVM_ABI bool hasPHIKill(const LiveInterval &LI, const VNInfo *VNI) const;
349
350 /// Add kill flags to any instruction that kills a virtual register.
351 LLVM_ABI void addKillFlags(const VirtRegMap *);
352
353 /// Call this method to notify LiveIntervals that instruction \p MI has been
354 /// moved within a basic block. This will update the live intervals for all
355 /// operands of \p MI. Moves between basic blocks are not supported.
356 ///
357 /// \param UpdateFlags Update live intervals for nonallocatable physregs.
358 LLVM_ABI void handleMove(MachineInstr &MI, bool UpdateFlags = false);
359
360 /// Update intervals of operands of all instructions in the newly
361 /// created bundle specified by \p BundleStart.
362 ///
363 /// \param UpdateFlags Update live intervals for nonallocatable physregs.
364 ///
365 /// Assumes existing liveness is accurate.
366 /// \pre BundleStart should be the first instruction in the Bundle.
367 /// \pre BundleStart should not have a have SlotIndex as one will be assigned.
369 bool UpdateFlags = false);
370
371 /// Update live intervals for instructions in a range of iterators. It is
372 /// intended for use after target hooks that may insert or remove
373 /// instructions, and is only efficient for a small number of instructions.
374 ///
375 /// OrigRegs is a vector of registers that were originally used by the
376 /// instructions in the range between the two iterators.
377 ///
378 /// Currently, the only changes that are supported are simple removal
379 /// and addition of uses.
383 ArrayRef<Register> OrigRegs);
384
385 // Register mask functions.
386 //
387 // Machine instructions may use a register mask operand to indicate that a
388 // large number of registers are clobbered by the instruction. This is
389 // typically used for calls.
390 //
391 // For compile time performance reasons, these clobbers are not recorded in
392 // the live intervals for individual physical registers. Instead,
393 // LiveIntervalAnalysis maintains a sorted list of instructions with
394 // register mask operands.
395
396 /// Returns a sorted array of slot indices of all instructions with
397 /// register mask operands.
398 ArrayRef<SlotIndex> getRegMaskSlots() const { return RegMaskSlots; }
399
400 /// Returns a sorted array of slot indices of all instructions with register
401 /// mask operands in the basic block numbered \p MBBNum.
403 std::pair<unsigned, unsigned> P = RegMaskBlocks[MBBNum];
404 return getRegMaskSlots().slice(P.first, P.second);
405 }
406
407 /// Returns an array of register mask pointers corresponding to
408 /// getRegMaskSlots().
409 ArrayRef<const uint32_t *> getRegMaskBits() const { return RegMaskBits; }
410
411 /// Returns an array of mask pointers corresponding to
412 /// getRegMaskSlotsInBlock(MBBNum).
414 std::pair<unsigned, unsigned> P = RegMaskBlocks[MBBNum];
415 return getRegMaskBits().slice(P.first, P.second);
416 }
417
418 /// Test if \p LI is live across any register mask instructions, and
419 /// compute a bit mask of physical registers that are not clobbered by any
420 /// of them.
421 ///
422 /// Returns false if \p LI doesn't cross any register mask instructions. In
423 /// that case, the bit vector is not filled in.
425 BitVector &UsableRegs);
426
427 // Register unit functions.
428 //
429 // Fixed interference occurs when MachineInstrs use physregs directly
430 // instead of virtual registers. This typically happens when passing
431 // arguments to a function call, or when instructions require operands in
432 // fixed registers.
433 //
434 // Each physreg has one or more register units, see MCRegisterInfo. We
435 // track liveness per register unit to handle aliasing registers more
436 // efficiently.
437
438 /// Return the live range for register unit \p Unit. It will be computed if
439 /// it doesn't exist.
440 LiveRange &getRegUnit(MCRegUnit Unit) {
441 LiveRange *LR = RegUnitRanges[static_cast<unsigned>(Unit)];
442 if (!LR) {
443 // Compute missing ranges on demand.
444 RegUnitRanges[static_cast<unsigned>(Unit)] = LR = createRegUnitRange();
445 computeRegUnitRange(*LR, Unit);
446 }
447 return *LR;
448 }
449
450 /// Return the live range for register unit \p Unit if it has already been
451 /// computed, or nullptr if it hasn't been computed yet.
452 LiveRange *getCachedRegUnit(MCRegUnit Unit) {
453 return RegUnitRanges[static_cast<unsigned>(Unit)];
454 }
455
456 const LiveRange *getCachedRegUnit(MCRegUnit Unit) const {
457 return RegUnitRanges[static_cast<unsigned>(Unit)];
458 }
459
460 /// Remove computed live range for register unit \p Unit. Subsequent uses
461 /// should rely on on-demand recomputation.
462 void removeRegUnit(MCRegUnit Unit) {
463 delete RegUnitRanges[static_cast<unsigned>(Unit)];
464 RegUnitRanges[static_cast<unsigned>(Unit)] = nullptr;
465 }
466
467 /// Remove associated live ranges for the register units associated with \p
468 /// Reg. Subsequent uses should rely on on-demand recomputation. \note This
469 /// method can result in inconsistent liveness tracking if multiple phyical
470 /// registers share a regunit, and should be used cautiously.
472 for (MCRegUnit Unit : TRI->regunits(Reg))
473 removeRegUnit(Unit);
474 }
475
476 /// Remove value numbers and related live segments starting at position
477 /// \p Pos that are part of any liverange of physical register \p Reg or one
478 /// of its subregisters.
480
481 /// Remove value number and related live segments of \p LI and its subranges
482 /// that start at position \p Pos.
484
485 /// Split separate components in LiveInterval \p LI into separate intervals.
486 LLVM_ABI void
489
490 /// For live interval \p LI with correct SubRanges construct matching
491 /// information for the main live range. Expects the main live range to not
492 /// have any segments or value numbers.
494
495private:
496 /// Compute live intervals for all virtual registers.
497 void computeVirtRegs();
498
499 /// Compute RegMaskSlots and RegMaskBits.
500 void computeRegMasks();
501
502 /// Implementation of insertMBBInMaps(). \p MBB must contain no regmask
503 /// operands when \p AssumeRegMaskEmpty is true.
504 LLVM_ABI void insertMBBInMapsImpl(MachineBasicBlock *MBB,
505 bool AssumeRegMaskEmpty);
506
507 /// Updates the regmask table for \p Orig's instructions that are moved into
508 /// \p SplitBB, so that the table is sliced across both blocks.
509 LLVM_ABI void reassignRegMaskSlots(MachineBasicBlock &Orig,
510 MachineBasicBlock &SplitBB);
511
512 /// Walk the values in \p LI and check for dead values:
513 /// - Dead PHIDef values are marked as unused.
514 /// - Dead operands are marked as such.
515 /// - Completely dead machine instructions are added to the \p dead vector
516 /// if it is not nullptr.
517 /// Returns true if any PHI value numbers have been removed which may
518 /// have separated the interval into multiple connected components.
519 bool computeDeadValues(LiveInterval &LI,
521
522 LLVM_ABI static LiveInterval *createInterval(Register Reg);
523 LLVM_ABI static LiveRange *createRegUnitRange();
524
525 void printInstrs(raw_ostream &O) const;
526 void dumpInstrs() const;
527
528 void computeLiveInRegUnits();
529 LLVM_ABI void computeRegUnitRange(LiveRange &, MCRegUnit Unit);
530 LLVM_ABI bool computeVirtRegInterval(LiveInterval &);
531
532 using ShrinkToUsesWorkList = SmallVector<std::pair<SlotIndex, VNInfo *>, 16>;
533 void extendSegmentsToUses(LiveRange &Segments, ShrinkToUsesWorkList &WorkList,
534 Register Reg, LaneBitmask LaneMask);
535
536 /// Helper function for repairIntervalsInRange(), walks backwards and
537 /// creates/modifies live segments in \p LR to match the operands found.
538 /// Only full operands or operands with subregisters matching \p LaneMask
539 /// are considered.
540 void repairOldRegInRange(MachineBasicBlock::iterator Begin,
542 const SlotIndex endIdx, LiveRange &LR, Register Reg,
543 LaneBitmask LaneMask = LaneBitmask::getAll());
544
545 class HMEditor;
546};
547
548class LiveIntervalsAnalysis : public AnalysisInfoMixin<LiveIntervalsAnalysis> {
550 LLVM_ABI static AnalysisKey Key;
551
552public:
556};
557
559 : public RequiredPassInfoMixin<LiveIntervalsPrinterPass> {
560 raw_ostream &OS;
561
562public:
563 explicit LiveIntervalsPrinterPass(raw_ostream &OS) : OS(OS) {}
566};
567
569 LiveIntervals LIS;
570
571public:
572 static char ID;
573
575
576 void getAnalysisUsage(AnalysisUsage &AU) const override;
577 void releaseMemory() override { LIS.clear(); }
578
579 /// Pass entry point; Calculates LiveIntervals.
580 bool runOnMachineFunction(MachineFunction &) override;
581
582 /// Implement the dump method.
583 void print(raw_ostream &O, const Module * = nullptr) const override {
584 LIS.print(O);
585 }
586
587 LiveIntervals &getLIS() { return LIS; }
588};
589
590} // end namespace llvm
591
592#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock & MBB
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_ABI
Definition Compiler.h:211
IRTranslator LLVM IR MI
This file implements an indexed map.
A common definition of LaneBitmask for use in TableGen and CodeGen.
#define I(x, y, z)
Definition MD5.cpp:57
Register Reg
std::pair< uint64_t, uint64_t > Interval
#define P(N)
This file defines the SmallVector class.
Represent the analysis usage information of a pass.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
A live range for subregisters.
LiveInterval - This class represents the liveness of a register, or stack slot.
LLVM_ABI Result run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
LLVM_ABI PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
LiveIntervalsPrinterPass(raw_ostream &OS)
void print(raw_ostream &O, const Module *=nullptr) const override
Implement the dump method.
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
LLVM_ABI void repairIntervalsInRange(MachineBasicBlock *MBB, MachineBasicBlock::iterator Begin, MachineBasicBlock::iterator End, ArrayRef< Register > OrigRegs)
Update live intervals for instructions in a range of iterators.
void removeAllRegUnitsForPhysReg(MCRegister Reg)
Remove associated live ranges for the register units associated with Reg.
bool hasInterval(Register Reg) const
SlotIndex getMBBStartIdx(const MachineBasicBlock *mbb) const
Return the first index in the given basic block.
MachineInstr * getInstructionFromIndex(SlotIndex index) const
Returns the instruction associated with the given index.
LLVM_ABI bool hasPHIKill(const LiveInterval &LI, const VNInfo *VNI) const
Returns true if VNI is killed by any PHI-def values in LI.
SlotIndex InsertMachineInstrInMaps(MachineInstr &MI)
LLVM_ABI bool checkRegMaskInterference(const LiveInterval &LI, BitVector &UsableRegs)
Test if LI is live across any register mask instructions, and compute a bit mask of physical register...
LiveIntervals(LiveIntervals &&)=default
LLVM_ABI void handleMove(MachineInstr &MI, bool UpdateFlags=false)
Call this method to notify LiveIntervals that instruction MI has been moved within a basic block.
void insertMBBInMaps(MachineBasicBlock *MBB)
Adds an empty block MBB to the SlotIndexes and regmask maps.
SlotIndexes * getSlotIndexes() const
LLVM_ABI unsigned removeUnreferencedIntervals()
Remove intervals for virtual registers no instruction refers to any more.
const LiveInterval & getInterval(Register Reg) const
ArrayRef< const uint32_t * > getRegMaskBits() const
Returns an array of register mask pointers corresponding to getRegMaskSlots().
LiveInterval & getOrCreateEmptyInterval(Register Reg)
Return an existing interval for Reg.
void reanalyze(MachineFunction &MF)
MachineDominatorTree & getDomTree()
LLVM_ABI void addKillFlags(const VirtRegMap *)
Add kill flags to any instruction that kills a virtual register.
SlotIndex getInstructionIndex(const MachineInstr &Instr) const
Returns the base index of the given instruction.
void removeRegUnit(MCRegUnit Unit)
Remove computed live range for register unit Unit.
LLVM_ABI bool invalidate(MachineFunction &MF, const PreservedAnalyses &PA, MachineFunctionAnalysisManager::Invalidator &Inv)
void RemoveMachineInstrFromMaps(MachineInstr &MI)
VNInfo::Allocator & getVNInfoAllocator()
ArrayRef< const uint32_t * > getRegMaskBitsInBlock(unsigned MBBNum) const
Returns an array of mask pointers corresponding to getRegMaskSlotsInBlock(MBBNum).
SlotIndex getMBBEndIdx(const MachineBasicBlock *mbb) const
Return the last index in the given basic block.
static LLVM_ABI float getSpillWeight(bool isDef, bool isUse, const MachineBlockFrequencyInfo *MBFI, const MachineInstr &MI, ProfileSummaryInfo *PSI=nullptr)
Calculate the spill weight to assign to a single instruction.
ArrayRef< SlotIndex > getRegMaskSlots() const
Returns a sorted array of slot indices of all instructions with register mask operands.
friend class LiveIntervalsWrapperPass
ArrayRef< SlotIndex > getRegMaskSlotsInBlock(unsigned MBBNum) const
Returns a sorted array of slot indices of all instructions with register mask operands in the basic b...
LiveInterval & getInterval(Register Reg)
void InsertMachineInstrRangeInMaps(MachineBasicBlock::iterator B, MachineBasicBlock::iterator E)
friend class LiveIntervalsAnalysis
LLVM_ABI void pruneValue(LiveRange &LR, SlotIndex Kill, SmallVectorImpl< SlotIndex > *EndPoints)
If LR has a live value at Kill, prune its live range by removing any liveness reachable from Kill.
LiveInterval & createAndComputeVirtRegInterval(Register Reg, bool &NeedSplit)
void removeInterval(Register Reg)
Interval removal.
bool isNotInMIMap(const MachineInstr &Instr) const
Returns true if the specified machine instr has been removed or was never entered in the map.
LLVM_ABI void handleMoveIntoNewBundle(MachineInstr &BundleStart, bool UpdateFlags=false)
Update intervals of operands of all instructions in the newly created bundle specified by BundleStart...
void pruneValue(LiveInterval &, SlotIndex, SmallVectorImpl< SlotIndex > *)
This function should not be used.
LiveRange & getRegUnit(MCRegUnit Unit)
Return the live range for register unit Unit.
LLVM_ABI MachineBasicBlock * intervalIsInOneMBB(const LiveInterval &LI) const
If LI is confined to a single basic block, return a pointer to that block.
const LiveRange * getCachedRegUnit(MCRegUnit Unit) const
LiveRange * getCachedRegUnit(MCRegUnit Unit)
Return the live range for register unit Unit if it has already been computed, or nullptr if it hasn't...
LLVM_ABI void removeVRegDefAt(LiveInterval &LI, SlotIndex Pos)
Remove value number and related live segments of LI and its subranges that start at position Pos.
LLVM_ABI LiveInterval::Segment addSegmentToEndOfBlock(Register Reg, MachineInstr &startInst)
Given a register and an instruction, adds a live segment from that instruction to the end of its MBB.
LLVM_ABI bool shrinkToUses(LiveInterval *li, SmallVectorImpl< MachineInstr * > *dead=nullptr)
After removing some uses of a register, shrink its live range to just the remaining uses.
LLVM_ABI void constructMainRangeFromSubranges(LiveInterval &LI)
For live interval LI with correct SubRanges construct matching information for the main live range.
LiveInterval & createEmptyInterval(Register Reg)
Interval creation.
LLVM_ABI void extendToIndices(LiveRange &LR, ArrayRef< SlotIndex > Indices, ArrayRef< SlotIndex > Undefs)
Extend the live range LR to reach all points in Indices.
LLVM_ABI void dump() const
void extendToIndices(LiveRange &LR, ArrayRef< SlotIndex > Indices)
bool isLiveOutOfMBB(const LiveRange &LR, const MachineBasicBlock *mbb) const
LLVM_ABI void print(raw_ostream &O) const
Implement the dump method.
LLVM_ABI void removePhysRegDefAt(MCRegister Reg, SlotIndex Pos)
Remove value numbers and related live segments starting at position Pos that are part of any liverang...
void splitAt(MachineBasicBlock &Orig, MachineBasicBlock &SplitBB)
After the tail of Orig has been sliced into SplitBB, updates the SlotIndexes and regmask maps and re-...
LLVM_ABI void splitSeparateComponents(LiveInterval &LI, SmallVectorImpl< LiveInterval * > &SplitLIs)
Split separate components in LiveInterval LI into separate intervals.
MachineBasicBlock * getMBBFromIndex(SlotIndex index) const
bool isLiveInToMBB(const LiveRange &LR, const MachineBasicBlock *mbb) const
LiveInterval & createAndComputeVirtRegInterval(Register Reg)
SlotIndex ReplaceMachineInstrInMaps(MachineInstr &MI, MachineInstr &NewMI)
This class represents the liveness of a register, stack slot, etc.
bool liveAt(SlotIndex index) const
Wrapper class representing physical registers. Should be passed by value.
Definition MCRegister.h:41
MachineInstrBundleIterator< MachineInstr > iterator
MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate machine basic b...
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
Representation of each machine instruction.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
Analysis providing profile information.
Wrapper class representing virtual and physical registers.
Definition Register.h:20
SlotIndex - An opaque wrapper around machine indexes.
Definition SlotIndexes.h:70
SlotIndexes pass.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
TargetInstrInfo - Interface to description of machine instruction set.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
VNInfo - Value Number Information.
BumpPtrAllocator Allocator
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
@ Kill
The last use of a register.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
@ End
Run the machine verifier once, at the end of the pipeline.
Definition CodeGen.h:267
A CRTP mix-in that provides informational APIs needed for analysis passes.
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition Analysis.h:29
static constexpr LaneBitmask getAll()
Definition LaneBitmask.h:82
This represents a simple continuous liveness interval for a value.
A CRTP mix-in for passes that should not be skipped.