LLVM 21.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
42extern cl::opt<bool> UseSegmentSetForPhysRegs;
43
44class BitVector;
45class MachineBlockFrequencyInfo;
46class MachineDominatorTree;
47class MachineFunction;
48class MachineInstr;
49class MachineRegisterInfo;
50class ProfileSummaryInfo;
51class raw_ostream;
52class TargetInstrInfo;
53class VirtRegMap;
54
58
59 MachineFunction *MF = nullptr;
60 MachineRegisterInfo *MRI = nullptr;
61 const TargetRegisterInfo *TRI = nullptr;
62 const TargetInstrInfo *TII = nullptr;
63 SlotIndexes *Indexes = nullptr;
64 MachineDominatorTree *DomTree = nullptr;
65 std::unique_ptr<LiveIntervalCalc> LICalc;
66
67 /// Special pool allocator for VNInfo's (LiveInterval val#).
68 VNInfo::Allocator VNInfoAllocator;
69
70 /// Live interval pointers for all the virtual registers.
72
73 /// Sorted list of instructions with register mask operands. Always use the
74 /// 'r' slot, RegMasks are normal clobbers, not early clobbers.
75 SmallVector<SlotIndex, 8> RegMaskSlots;
76
77 /// This vector is parallel to RegMaskSlots, it holds a pointer to the
78 /// corresponding register mask. This pointer can be recomputed as:
79 ///
80 /// MI = Indexes->getInstructionFromIndex(RegMaskSlot[N]);
81 /// unsigned OpNum = findRegMaskOperand(MI);
82 /// RegMaskBits[N] = MI->getOperand(OpNum).getRegMask();
83 ///
84 /// This is kept in a separate vector partly because some standard
85 /// libraries don't support lower_bound() with mixed objects, partly to
86 /// improve locality when searching in RegMaskSlots.
87 /// Also see the comment in LiveInterval::find().
89
90 /// For each basic block number, keep (begin, size) pairs indexing into the
91 /// RegMaskSlots and RegMaskBits arrays.
92 /// Note that basic block numbers may not be layout contiguous, that's why
93 /// we can't just keep track of the first register mask in each basic
94 /// block.
96
97 /// Keeps a live range set for each register unit to track fixed physreg
98 /// interference.
99 SmallVector<LiveRange *, 0> RegUnitRanges;
100
101 // Can only be created from pass manager.
102 LiveIntervals() = default;
104 : Indexes(&SI), DomTree(&DT) {
105 analyze(MF);
106 }
107
108 void analyze(MachineFunction &MF);
109
110 void clear();
111
112public:
115
116 bool invalidate(MachineFunction &MF, const PreservedAnalyses &PA,
118
119 /// Calculate the spill weight to assign to a single instruction.
120 /// If \p PSI is provided the calculation is altered for optsize functions.
121 static float getSpillWeight(bool isDef, bool isUse,
122 const MachineBlockFrequencyInfo *MBFI,
123 const MachineInstr &MI,
124 ProfileSummaryInfo *PSI = nullptr);
125
126 /// Calculate the spill weight to assign to a single instruction.
127 /// If \p PSI is provided the calculation is altered for optsize functions.
128 static float getSpillWeight(bool isDef, bool isUse,
129 const MachineBlockFrequencyInfo *MBFI,
130 const MachineBasicBlock *MBB,
131 ProfileSummaryInfo *PSI = nullptr);
132
134 if (hasInterval(Reg))
135 return *VirtRegIntervals[Reg.id()];
136
138 }
139
141 return const_cast<LiveIntervals *>(this)->getInterval(Reg);
142 }
143
145 return VirtRegIntervals.inBounds(Reg.id()) && VirtRegIntervals[Reg.id()];
146 }
147
148 /// Interval creation.
150 assert(!hasInterval(Reg) && "Interval already exists!");
151 VirtRegIntervals.grow(Reg.id());
152 auto &Interval = VirtRegIntervals[Reg.id()];
153 Interval = createInterval(Reg);
154 return *Interval;
155 }
156
159 computeVirtRegInterval(LI);
160 return LI;
161 }
162
163 /// Return an existing interval for \p Reg.
164 /// If \p Reg has no interval then this creates a new empty one instead.
165 /// Note: does not trigger interval computation.
168 }
169
170 /// Interval removal.
172 auto &Interval = VirtRegIntervals[Reg];
173 delete Interval;
174 Interval = nullptr;
175 }
176
177 /// Given a register and an instruction, adds a live segment from that
178 /// instruction to the end of its MBB.
180 MachineInstr &startInst);
181
182 /// After removing some uses of a register, shrink its live range to just
183 /// the remaining uses. This method does not compute reaching defs for new
184 /// uses, and it doesn't remove dead defs.
185 /// Dead PHIDef values are marked as unused. New dead machine instructions
186 /// are added to the dead vector. Returns true if the interval may have been
187 /// separated into multiple connected components.
188 bool shrinkToUses(LiveInterval *li,
189 SmallVectorImpl<MachineInstr *> *dead = nullptr);
190
191 /// Specialized version of
192 /// shrinkToUses(LiveInterval *li, SmallVectorImpl<MachineInstr*> *dead)
193 /// that works on a subregister live range and only looks at uses matching
194 /// the lane mask of the subregister range.
195 /// This may leave the subrange empty which needs to be cleaned up with
196 /// LiveInterval::removeEmptySubranges() afterwards.
198
199 /// Extend the live range \p LR to reach all points in \p Indices. The
200 /// points in the \p Indices array must be jointly dominated by the union
201 /// of the existing defs in \p LR and points in \p Undefs.
202 ///
203 /// PHI-defs are added as needed to maintain SSA form.
204 ///
205 /// If a SlotIndex in \p Indices is the end index of a basic block, \p LR
206 /// will be extended to be live out of the basic block.
207 /// If a SlotIndex in \p Indices is jointy dominated only by points in
208 /// \p Undefs, the live range will not be extended to that point.
209 ///
210 /// See also LiveRangeCalc::extend().
212 ArrayRef<SlotIndex> Undefs);
213
215 extendToIndices(LR, Indices, /*Undefs=*/{});
216 }
217
218 /// If \p LR has a live value at \p Kill, prune its live range by removing
219 /// any liveness reachable from Kill. Add live range end points to
220 /// EndPoints such that extendToIndices(LI, EndPoints) will reconstruct the
221 /// value's live range.
222 ///
223 /// Calling pruneValue() and extendToIndices() can be used to reconstruct
224 /// SSA form after adding defs to a virtual register.
225 void pruneValue(LiveRange &LR, SlotIndex Kill,
226 SmallVectorImpl<SlotIndex> *EndPoints);
227
228 /// This function should not be used. Its intent is to tell you that you are
229 /// doing something wrong if you call pruneValue directly on a
230 /// LiveInterval. Indeed, you are supposed to call pruneValue on the main
231 /// LiveRange and all the LiveRanges of the subranges if any.
235 "Use pruneValue on the main LiveRange and on each subrange");
236 }
237
238 SlotIndexes *getSlotIndexes() const { return Indexes; }
239
240 /// Returns true if the specified machine instr has been removed or was
241 /// never entered in the map.
242 bool isNotInMIMap(const MachineInstr &Instr) const {
243 return !Indexes->hasIndex(Instr);
244 }
245
246 /// Returns the base index of the given instruction.
248 return Indexes->getInstructionIndex(Instr);
249 }
250
251 /// Returns the instruction associated with the given index.
253 return Indexes->getInstructionFromIndex(index);
254 }
255
256 /// Return the first index in the given basic block.
258 return Indexes->getMBBStartIdx(mbb);
259 }
260
261 /// Return the last index in the given basic block.
263 return Indexes->getMBBEndIdx(mbb);
264 }
265
266 bool isLiveInToMBB(const LiveRange &LR, const MachineBasicBlock *mbb) const {
267 return LR.liveAt(getMBBStartIdx(mbb));
268 }
269
270 bool isLiveOutOfMBB(const LiveRange &LR, const MachineBasicBlock *mbb) const {
271 return LR.liveAt(getMBBEndIdx(mbb).getPrevSlot());
272 }
273
275 return Indexes->getMBBFromIndex(index);
276 }
277
279 Indexes->insertMBBInMaps(MBB);
280 assert(unsigned(MBB->getNumber()) == RegMaskBlocks.size() &&
281 "Blocks must be added in order.");
282 RegMaskBlocks.push_back(std::make_pair(RegMaskSlots.size(), 0));
283 }
284
286 return Indexes->insertMachineInstrInMaps(MI);
287 }
288
291 for (MachineBasicBlock::iterator I = B; I != E; ++I)
292 Indexes->insertMachineInstrInMaps(*I);
293 }
294
297 }
298
300 return Indexes->replaceMachineInstrInMaps(MI, NewMI);
301 }
302
303 VNInfo::Allocator &getVNInfoAllocator() { return VNInfoAllocator; }
304
305 /// Implement the dump method.
306 void print(raw_ostream &O) const;
307 void dump() const;
308
309 // For legacy pass to recompute liveness.
311 clear();
312 analyze(MF);
313 }
314
315 MachineDominatorTree &getDomTree() { return *DomTree; }
316
317 /// If LI is confined to a single basic block, return a pointer to that
318 /// block. If LI is live in to or out of any block, return NULL.
320
321 /// Returns true if VNI is killed by any PHI-def values in LI.
322 /// This may conservatively return true to avoid expensive computations.
323 bool hasPHIKill(const LiveInterval &LI, const VNInfo *VNI) const;
324
325 /// Add kill flags to any instruction that kills a virtual register.
326 void addKillFlags(const VirtRegMap *);
327
328 /// Call this method to notify LiveIntervals that instruction \p MI has been
329 /// moved within a basic block. This will update the live intervals for all
330 /// operands of \p MI. Moves between basic blocks are not supported.
331 ///
332 /// \param UpdateFlags Update live intervals for nonallocatable physregs.
333 void handleMove(MachineInstr &MI, bool UpdateFlags = false);
334
335 /// Update intervals of operands of all instructions in the newly
336 /// created bundle specified by \p BundleStart.
337 ///
338 /// \param UpdateFlags Update live intervals for nonallocatable physregs.
339 ///
340 /// Assumes existing liveness is accurate.
341 /// \pre BundleStart should be the first instruction in the Bundle.
342 /// \pre BundleStart should not have a have SlotIndex as one will be assigned.
343 void handleMoveIntoNewBundle(MachineInstr &BundleStart,
344 bool UpdateFlags = false);
345
346 /// Update live intervals for instructions in a range of iterators. It is
347 /// intended for use after target hooks that may insert or remove
348 /// instructions, and is only efficient for a small number of instructions.
349 ///
350 /// OrigRegs is a vector of registers that were originally used by the
351 /// instructions in the range between the two iterators.
352 ///
353 /// Currently, the only changes that are supported are simple removal
354 /// and addition of uses.
358 ArrayRef<Register> OrigRegs);
359
360 // Register mask functions.
361 //
362 // Machine instructions may use a register mask operand to indicate that a
363 // large number of registers are clobbered by the instruction. This is
364 // typically used for calls.
365 //
366 // For compile time performance reasons, these clobbers are not recorded in
367 // the live intervals for individual physical registers. Instead,
368 // LiveIntervalAnalysis maintains a sorted list of instructions with
369 // register mask operands.
370
371 /// Returns a sorted array of slot indices of all instructions with
372 /// register mask operands.
373 ArrayRef<SlotIndex> getRegMaskSlots() const { return RegMaskSlots; }
374
375 /// Returns a sorted array of slot indices of all instructions with register
376 /// mask operands in the basic block numbered \p MBBNum.
378 std::pair<unsigned, unsigned> P = RegMaskBlocks[MBBNum];
379 return getRegMaskSlots().slice(P.first, P.second);
380 }
381
382 /// Returns an array of register mask pointers corresponding to
383 /// getRegMaskSlots().
384 ArrayRef<const uint32_t *> getRegMaskBits() const { return RegMaskBits; }
385
386 /// Returns an array of mask pointers corresponding to
387 /// getRegMaskSlotsInBlock(MBBNum).
389 std::pair<unsigned, unsigned> P = RegMaskBlocks[MBBNum];
390 return getRegMaskBits().slice(P.first, P.second);
391 }
392
393 /// Test if \p LI is live across any register mask instructions, and
394 /// compute a bit mask of physical registers that are not clobbered by any
395 /// of them.
396 ///
397 /// Returns false if \p LI doesn't cross any register mask instructions. In
398 /// that case, the bit vector is not filled in.
399 bool checkRegMaskInterference(const LiveInterval &LI, BitVector &UsableRegs);
400
401 // Register unit functions.
402 //
403 // Fixed interference occurs when MachineInstrs use physregs directly
404 // instead of virtual registers. This typically happens when passing
405 // arguments to a function call, or when instructions require operands in
406 // fixed registers.
407 //
408 // Each physreg has one or more register units, see MCRegisterInfo. We
409 // track liveness per register unit to handle aliasing registers more
410 // efficiently.
411
412 /// Return the live range for register unit \p Unit. It will be computed if
413 /// it doesn't exist.
414 LiveRange &getRegUnit(unsigned Unit) {
415 LiveRange *LR = RegUnitRanges[Unit];
416 if (!LR) {
417 // Compute missing ranges on demand.
418 // Use segment set to speed-up initial computation of the live range.
419 RegUnitRanges[Unit] = LR = new LiveRange(UseSegmentSetForPhysRegs);
420 computeRegUnitRange(*LR, Unit);
421 }
422 return *LR;
423 }
424
425 /// Return the live range for register unit \p Unit if it has already been
426 /// computed, or nullptr if it hasn't been computed yet.
427 LiveRange *getCachedRegUnit(unsigned Unit) { return RegUnitRanges[Unit]; }
428
429 const LiveRange *getCachedRegUnit(unsigned Unit) const {
430 return RegUnitRanges[Unit];
431 }
432
433 /// Remove computed live range for register unit \p Unit. Subsequent uses
434 /// should rely on on-demand recomputation.
435 void removeRegUnit(unsigned Unit) {
436 delete RegUnitRanges[Unit];
437 RegUnitRanges[Unit] = nullptr;
438 }
439
440 /// Remove associated live ranges for the register units associated with \p
441 /// Reg. Subsequent uses should rely on on-demand recomputation. \note This
442 /// method can result in inconsistent liveness tracking if multiple phyical
443 /// registers share a regunit, and should be used cautiously.
445 for (MCRegUnit Unit : TRI->regunits(Reg))
446 removeRegUnit(Unit);
447 }
448
449 /// Remove value numbers and related live segments starting at position
450 /// \p Pos that are part of any liverange of physical register \p Reg or one
451 /// of its subregisters.
453
454 /// Remove value number and related live segments of \p LI and its subranges
455 /// that start at position \p Pos.
457
458 /// Split separate components in LiveInterval \p LI into separate intervals.
461
462 /// For live interval \p LI with correct SubRanges construct matching
463 /// information for the main live range. Expects the main live range to not
464 /// have any segments or value numbers.
466
467private:
468 /// Compute live intervals for all virtual registers.
469 void computeVirtRegs();
470
471 /// Compute RegMaskSlots and RegMaskBits.
472 void computeRegMasks();
473
474 /// Walk the values in \p LI and check for dead values:
475 /// - Dead PHIDef values are marked as unused.
476 /// - Dead operands are marked as such.
477 /// - Completely dead machine instructions are added to the \p dead vector
478 /// if it is not nullptr.
479 /// Returns true if any PHI value numbers have been removed which may
480 /// have separated the interval into multiple connected components.
481 bool computeDeadValues(LiveInterval &LI,
483
484 static LiveInterval *createInterval(Register Reg);
485
486 void printInstrs(raw_ostream &O) const;
487 void dumpInstrs() const;
488
489 void computeLiveInRegUnits();
490 void computeRegUnitRange(LiveRange &, unsigned Unit);
491 bool computeVirtRegInterval(LiveInterval &);
492
493 using ShrinkToUsesWorkList = SmallVector<std::pair<SlotIndex, VNInfo *>, 16>;
494 void extendSegmentsToUses(LiveRange &Segments, ShrinkToUsesWorkList &WorkList,
495 Register Reg, LaneBitmask LaneMask);
496
497 /// Helper function for repairIntervalsInRange(), walks backwards and
498 /// creates/modifies live segments in \p LR to match the operands found.
499 /// Only full operands or operands with subregisters matching \p LaneMask
500 /// are considered.
501 void repairOldRegInRange(MachineBasicBlock::iterator Begin,
503 const SlotIndex endIdx, LiveRange &LR, Register Reg,
504 LaneBitmask LaneMask = LaneBitmask::getAll());
505
506 class HMEditor;
507};
508
509class LiveIntervalsAnalysis : public AnalysisInfoMixin<LiveIntervalsAnalysis> {
511 static AnalysisKey Key;
512
513public:
516};
517
519 : public PassInfoMixin<LiveIntervalsPrinterPass> {
520 raw_ostream &OS;
521
522public:
526 static bool isRequired() { return true; }
527};
528
530 LiveIntervals LIS;
531
532public:
533 static char ID;
534
536
537 void getAnalysisUsage(AnalysisUsage &AU) const override;
538 void releaseMemory() override { LIS.clear(); }
539
540 /// Pass entry point; Calculates LiveIntervals.
541 bool runOnMachineFunction(MachineFunction &) override;
542
543 /// Implement the dump method.
544 void print(raw_ostream &O, const Module * = nullptr) const override {
545 LIS.print(O);
546 }
547
548 LiveIntervals &getLIS() { return LIS; }
549};
550
551} // end namespace llvm
552
553#endif
unsigned const MachineRegisterInfo * MRI
MachineBasicBlock & MBB
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_ATTRIBUTE_UNUSED
Definition: Compiler.h:282
bool End
Definition: ELF_riscv.cpp:480
const HexagonInstrInfo * TII
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:58
unsigned const TargetRegisterInfo * TRI
unsigned Reg
std::pair< uint64_t, uint64_t > Interval
#define P(N)
StandardInstrumentations SI(Mod->getContext(), Debug, VerifyEach)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
SI Optimize VGPR LiveRange
raw_pwrite_stream & OS
This file defines the SmallVector class.
API to communicate dependencies between analyses during invalidation.
Definition: PassManager.h:292
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:253
Represent the analysis usage information of a pass.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:66
void grow(IndexT n)
Definition: IndexedMap.h:69
bool inBounds(IndexT n) const
Definition: IndexedMap.h:75
A live range for subregisters.
Definition: LiveInterval.h:694
LiveInterval - This class represents the liveness of a register, or stack slot.
Definition: LiveInterval.h:687
Result run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
LiveIntervalsPrinterPass(raw_ostream &OS)
bool runOnMachineFunction(MachineFunction &) override
Pass entry point; Calculates LiveIntervals.
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...
const LiveRange * getCachedRegUnit(unsigned Unit) const
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.
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)
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
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)
SlotIndexes * getSlotIndexes() const
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()
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.
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 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.
LiveRange & getRegUnit(unsigned Unit)
Return the live range for register unit Unit.
ArrayRef< SlotIndex > getRegMaskSlotsInBlock(unsigned MBBNum) const
Returns a sorted array of slot indices of all instructions with register mask operands in the basic b...
LiveRange * getCachedRegUnit(unsigned Unit)
Return the live range for register unit Unit if it has already been computed, or nullptr if it hasn't...
LiveInterval & getInterval(Register Reg)
void InsertMachineInstrRangeInMaps(MachineBasicBlock::iterator B, MachineBasicBlock::iterator E)
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.
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.
void handleMoveIntoNewBundle(MachineInstr &BundleStart, bool UpdateFlags=false)
Update intervals of operands of all instructions in the newly created bundle specified by BundleStart...
MachineBasicBlock * intervalIsInOneMBB(const LiveInterval &LI) const
If LI is confined to a single basic block, return a pointer to that block.
void removeVRegDefAt(LiveInterval &LI, SlotIndex Pos)
Remove value number and related live segments of LI and its subranges that start at position Pos.
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.
void removeRegUnit(unsigned Unit)
Remove computed live range for register unit Unit.
bool shrinkToUses(LiveInterval *li, SmallVectorImpl< MachineInstr * > *dead=nullptr)
After removing some uses of a register, shrink its live range to just the remaining uses.
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.
void extendToIndices(LiveRange &LR, ArrayRef< SlotIndex > Indices, ArrayRef< SlotIndex > Undefs)
Extend the live range LR to reach all points in Indices.
void extendToIndices(LiveRange &LR, ArrayRef< SlotIndex > Indices)
bool isLiveOutOfMBB(const LiveRange &LR, const MachineBasicBlock *mbb) const
void print(raw_ostream &O) const
Implement the dump method.
LLVM_ATTRIBUTE_UNUSED void pruneValue(LiveInterval &, SlotIndex, SmallVectorImpl< SlotIndex > *)
This function should not be used.
void removePhysRegDefAt(MCRegister Reg, SlotIndex Pos)
Remove value numbers and related live segments starting at position Pos that are part of any liverang...
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.
Definition: LiveInterval.h:157
bool liveAt(SlotIndex index) const
Definition: LiveInterval.h:401
Wrapper class representing physical registers. Should be passed by value.
Definition: MCRegister.h:33
MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate machine basic b...
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
Representation of each machine instruction.
Definition: MachineInstr.h:71
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:65
A set of analyses that are preserved following a run of a transformation pass.
Definition: Analysis.h:111
Analysis providing profile information.
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
SlotIndex - An opaque wrapper around machine indexes.
Definition: SlotIndexes.h:65
SlotIndexes pass.
Definition: SlotIndexes.h:297
SlotIndex insertMachineInstrInMaps(MachineInstr &MI, bool Late=false)
Insert the given machine instruction into the mapping.
Definition: SlotIndexes.h:531
void removeMachineInstrFromMaps(MachineInstr &MI, bool AllowBundled=false)
Removes machine instruction (bundle) MI from the mapping.
MachineBasicBlock * getMBBFromIndex(SlotIndex index) const
Returns the basic block which the given index falls in.
Definition: SlotIndexes.h:515
void insertMBBInMaps(MachineBasicBlock *mbb)
Add the given MachineBasicBlock into the maps.
Definition: SlotIndexes.h:606
SlotIndex getMBBEndIdx(unsigned Num) const
Returns the last index in the given basic block number.
Definition: SlotIndexes.h:470
SlotIndex getInstructionIndex(const MachineInstr &MI, bool IgnoreBundle=false) const
Returns the base index for the given instruction.
Definition: SlotIndexes.h:379
SlotIndex getMBBStartIdx(unsigned Num) const
Returns the first index in the given basic block number.
Definition: SlotIndexes.h:460
bool hasIndex(const MachineInstr &instr) const
Returns true if the given machine instr is mapped to an index, otherwise returns false.
Definition: SlotIndexes.h:374
SlotIndex replaceMachineInstrInMaps(MachineInstr &MI, MachineInstr &NewMI)
ReplaceMachineInstrInMaps - Replacing a machine instr with a new one in maps used by register allocat...
Definition: SlotIndexes.h:588
MachineInstr * getInstructionFromIndex(SlotIndex index) const
Returns the instruction for the given index, or null if the given index has no instruction associated...
Definition: SlotIndexes.h:397
size_t size() const
Definition: SmallVector.h:78
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:573
void push_back(const T &Elt)
Definition: SmallVector.h:413
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1196
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.
Definition: LiveInterval.h:53
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
#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.
Definition: AddressRanges.h:18
cl::opt< bool > UseSegmentSetForPhysRegs
A CRTP mix-in that provides informational APIs needed for analysis passes.
Definition: PassManager.h:92
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: Analysis.h:28
static constexpr LaneBitmask getAll()
Definition: LaneBitmask.h:82
This represents a simple continuous liveness interval for a value.
Definition: LiveInterval.h:162
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:69