LLVM 24.0.0git
RenameIndependentSubregs.cpp
Go to the documentation of this file.
1//===-- RenameIndependentSubregs.cpp - Live Interval Analysis -------------===//
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/// Rename independent subregisters looks for virtual registers with
10/// independently used subregisters and renames them to new virtual registers.
11/// Example: In the following:
12/// %0:sub0<read-undef> = ...
13/// %0:sub1 = ...
14/// use %0:sub0
15/// %0:sub0 = ...
16/// use %0:sub0
17/// use %0:sub1
18/// sub0 and sub1 are never used together, and we have two independent sub0
19/// definitions. This pass will rename to:
20/// %0:sub0<read-undef> = ...
21/// %1:sub1<read-undef> = ...
22/// use %1:sub1
23/// %2:sub1<read-undef> = ...
24/// use %2:sub1
25/// use %0:sub0
26//
27//===----------------------------------------------------------------------===//
28
30#include "LiveRangeUtils.h"
31#include "PHIEliminationUtils.h"
40#include "llvm/Pass.h"
41
42using namespace llvm;
43
44#define DEBUG_TYPE "rename-independent-subregs"
45
46namespace {
47
48class RenameIndependentSubregs {
49public:
50 RenameIndependentSubregs(LiveIntervals *LIS) : LIS(LIS) {}
51
52 bool run(MachineFunction &MF);
53
54private:
55 struct SubRangeInfo {
58 unsigned Index;
59
60 SubRangeInfo(LiveIntervals &LIS, LiveInterval::SubRange &SR,
61 unsigned Index)
62 : ConEQ(LIS), SR(&SR), Index(Index) {}
63 };
64
65 /// Split unrelated subregister components and rename them to new vregs.
66 bool renameComponents(LiveInterval &LI) const;
67
68 /// Build a vector of SubRange infos and a union find set of
69 /// equivalence classes.
70 /// Returns true if more than 1 equivalence class was found.
71 bool findComponents(IntEqClasses &Classes,
72 SmallVectorImpl<SubRangeInfo> &SubRangeInfos,
73 LiveInterval &LI) const;
74
75 /// Distribute the LiveInterval segments into the new LiveIntervals
76 /// belonging to their class.
77 void distribute(const IntEqClasses &Classes,
78 const SmallVectorImpl<SubRangeInfo> &SubRangeInfos,
79 const SmallVectorImpl<LiveInterval*> &Intervals) const;
80
81 /// Constructs main liverange and add missing undef+dead flags.
82 void computeMainRangesFixFlags(const IntEqClasses &Classes,
83 const SmallVectorImpl<SubRangeInfo> &SubRangeInfos,
84 const SmallVectorImpl<LiveInterval*> &Intervals) const;
85
86 /// Rewrite Machine Operands to use the new vreg belonging to their class.
87 void rewriteOperands(const IntEqClasses &Classes,
88 const SmallVectorImpl<SubRangeInfo> &SubRangeInfos,
89 const SmallVectorImpl<LiveInterval*> &Intervals) const;
90
91
92 LiveIntervals *LIS = nullptr;
93 MachineRegisterInfo *MRI = nullptr;
94 const TargetInstrInfo *TII = nullptr;
95};
96
97class RenameIndependentSubregsLegacy : public MachineFunctionPass {
98public:
99 static char ID;
100 RenameIndependentSubregsLegacy() : MachineFunctionPass(ID) {}
101 bool runOnMachineFunction(MachineFunction &MF) override;
102 StringRef getPassName() const override {
103 return "Rename Disconnected Subregister Components";
104 }
105
106 void getAnalysisUsage(AnalysisUsage &AU) const override {
107 AU.setPreservesCFG();
114 }
115};
116
117} // end anonymous namespace
118
119char RenameIndependentSubregsLegacy::ID;
120
121char &llvm::RenameIndependentSubregsID = RenameIndependentSubregsLegacy::ID;
122
123INITIALIZE_PASS_BEGIN(RenameIndependentSubregsLegacy, DEBUG_TYPE,
124 "Rename Independent Subregisters", false, false)
127INITIALIZE_PASS_END(RenameIndependentSubregsLegacy, DEBUG_TYPE,
128 "Rename Independent Subregisters", false, false)
129
130bool RenameIndependentSubregs::renameComponents(LiveInterval &LI) const {
131 // Shortcut: We cannot have split components with a single definition.
132 if (LI.valnos.size() < 2)
133 return false;
134
135 SmallVector<SubRangeInfo, 4> SubRangeInfos;
136 IntEqClasses Classes;
137 if (!findComponents(Classes, SubRangeInfos, LI))
138 return false;
139
140 // Create a new VReg for each class.
141 Register Reg = LI.reg();
142 const TargetRegisterClass *RegClass = MRI->getRegClass(Reg);
144 Intervals.push_back(&LI);
145 LLVM_DEBUG(dbgs() << printReg(Reg) << ": Found " << Classes.getNumClasses()
146 << " equivalence classes.\n");
147 LLVM_DEBUG(dbgs() << printReg(Reg) << ": Splitting into newly created:");
148 for (unsigned I = 1, NumClasses = Classes.getNumClasses(); I < NumClasses;
149 ++I) {
150 Register NewVReg = MRI->createVirtualRegister(RegClass);
151 LiveInterval &NewLI = LIS->createEmptyInterval(NewVReg);
152 Intervals.push_back(&NewLI);
153 LLVM_DEBUG(dbgs() << ' ' << printReg(NewVReg));
154 }
155 LLVM_DEBUG(dbgs() << '\n');
156
157 rewriteOperands(Classes, SubRangeInfos, Intervals);
158 distribute(Classes, SubRangeInfos, Intervals);
159 computeMainRangesFixFlags(Classes, SubRangeInfos, Intervals);
160 return true;
161}
162
163bool RenameIndependentSubregs::findComponents(IntEqClasses &Classes,
165 LiveInterval &LI) const {
166 // First step: Create connected components for the VNInfos inside the
167 // subranges and count the global number of such components.
168 unsigned NumComponents = 0;
169 for (LiveInterval::SubRange &SR : LI.subranges()) {
170 SubRangeInfos.push_back(SubRangeInfo(*LIS, SR, NumComponents));
171 ConnectedVNInfoEqClasses &ConEQ = SubRangeInfos.back().ConEQ;
172
173 unsigned NumSubComponents = ConEQ.Classify(SR);
174 NumComponents += NumSubComponents;
175 }
176 // Shortcut: With only 1 subrange, the normal separate component tests are
177 // enough and we do not need to perform the union-find on the subregister
178 // segments.
179 if (SubRangeInfos.size() < 2)
180 return false;
181
182 // Next step: Build union-find structure over all subranges and merge classes
183 // across subranges when they are affected by the same MachineOperand.
184 const TargetRegisterInfo &TRI = *MRI->getTargetRegisterInfo();
185 Classes.grow(NumComponents);
186 Register Reg = LI.reg();
187 for (const MachineOperand &MO : MRI->reg_nodbg_operands(Reg)) {
188 if (!MO.isDef() && !MO.readsReg())
189 continue;
190 unsigned SubRegIdx = MO.getSubReg();
191 LaneBitmask LaneMask = TRI.getSubRegIndexLaneMask(SubRegIdx);
192 unsigned MergedID = ~0u;
193 for (RenameIndependentSubregs::SubRangeInfo &SRInfo : SubRangeInfos) {
194 const LiveInterval::SubRange &SR = *SRInfo.SR;
195 if ((SR.LaneMask & LaneMask).none())
196 continue;
197 SlotIndex Pos = LIS->getInstructionIndex(*MO.getParent());
198 Pos = MO.isDef() ? Pos.getRegSlot(MO.isEarlyClobber())
199 : Pos.getBaseIndex();
200 const VNInfo *VNI = SR.getVNInfoAt(Pos);
201 if (VNI == nullptr)
202 continue;
203
204 // Map to local representant ID.
205 unsigned LocalID = SRInfo.ConEQ.getEqClass(VNI);
206 // Global ID
207 unsigned ID = LocalID + SRInfo.Index;
208 // Merge other sets
209 MergedID = MergedID == ~0u ? ID : Classes.join(MergedID, ID);
210 }
211 }
212
213 // Early exit if we ended up with a single equivalence class.
214 Classes.compress();
215 unsigned NumClasses = Classes.getNumClasses();
216 return NumClasses > 1;
217}
218
219void RenameIndependentSubregs::rewriteOperands(const IntEqClasses &Classes,
220 const SmallVectorImpl<SubRangeInfo> &SubRangeInfos,
221 const SmallVectorImpl<LiveInterval*> &Intervals) const {
222 const TargetRegisterInfo &TRI = *MRI->getTargetRegisterInfo();
223 Register Reg = Intervals[0]->reg();
225 E = MRI->reg_nodbg_end(); I != E; ) {
226 MachineOperand &MO = *I++;
227 if (!MO.isDef() && !MO.readsReg())
228 continue;
229
230 auto *MI = MO.getParent();
231 SlotIndex Pos = LIS->getInstructionIndex(*MI);
232 Pos = MO.isDef() ? Pos.getRegSlot(MO.isEarlyClobber())
233 : Pos.getBaseIndex();
234 unsigned SubRegIdx = MO.getSubReg();
235 LaneBitmask LaneMask = TRI.getSubRegIndexLaneMask(SubRegIdx);
236
237 unsigned ID = ~0u;
238 for (const SubRangeInfo &SRInfo : SubRangeInfos) {
239 const LiveInterval::SubRange &SR = *SRInfo.SR;
240 if ((SR.LaneMask & LaneMask).none())
241 continue;
242 const VNInfo *VNI = SR.getVNInfoAt(Pos);
243 if (VNI == nullptr)
244 continue;
245
246 // Map to local representant ID.
247 unsigned LocalID = SRInfo.ConEQ.getEqClass(VNI);
248 // Global ID
249 ID = Classes[LocalID + SRInfo.Index];
250 break;
251 }
252
253 Register VReg = Intervals[ID]->reg();
254 MO.setReg(VReg);
255
256 if (MO.isTied() && Reg != VReg) {
257 /// Undef use operands are not tracked in the equivalence class,
258 /// but need to be updated if they are tied; take care to only
259 /// update the tied operand.
260 unsigned OperandNo = MO.getOperandNo();
261 unsigned TiedIdx = MI->findTiedOperandIdx(OperandNo);
262 MI->getOperand(TiedIdx).setReg(VReg);
263
264 // above substitution breaks the iterator, so restart.
265 I = MRI->reg_nodbg_begin(Reg);
266 }
267 }
268 // TODO: We could attempt to recompute new register classes while visiting
269 // the operands: Some of the split register may be fine with less constraint
270 // classes than the original vreg.
271}
272
273void RenameIndependentSubregs::distribute(const IntEqClasses &Classes,
274 const SmallVectorImpl<SubRangeInfo> &SubRangeInfos,
275 const SmallVectorImpl<LiveInterval*> &Intervals) const {
276 unsigned NumClasses = Classes.getNumClasses();
277 SmallVector<unsigned, 8> VNIMapping;
280 for (const SubRangeInfo &SRInfo : SubRangeInfos) {
281 LiveInterval::SubRange &SR = *SRInfo.SR;
282 unsigned NumValNos = SR.valnos.size();
283 VNIMapping.clear();
284 VNIMapping.reserve(NumValNos);
285 SubRanges.clear();
286 SubRanges.resize(NumClasses-1, nullptr);
287 for (unsigned I = 0; I < NumValNos; ++I) {
288 const VNInfo &VNI = *SR.valnos[I];
289 unsigned LocalID = SRInfo.ConEQ.getEqClass(&VNI);
290 unsigned ID = Classes[LocalID + SRInfo.Index];
291 VNIMapping.push_back(ID);
292 if (ID > 0 && SubRanges[ID-1] == nullptr)
293 SubRanges[ID-1] = Intervals[ID]->createSubRange(Allocator, SR.LaneMask);
294 }
295 DistributeRange(SR, SubRanges.data(), VNIMapping);
296 }
297}
298
299static bool subRangeLiveAt(const LiveInterval &LI, SlotIndex Pos) {
300 for (const LiveInterval::SubRange &SR : LI.subranges()) {
301 if (SR.liveAt(Pos))
302 return true;
303 }
304 return false;
305}
306
307void RenameIndependentSubregs::computeMainRangesFixFlags(
308 const IntEqClasses &Classes,
309 const SmallVectorImpl<SubRangeInfo> &SubRangeInfos,
310 const SmallVectorImpl<LiveInterval*> &Intervals) const {
311 const TargetRegisterInfo &TRI = TII->getRegisterInfo();
313 const SlotIndexes &Indexes = *LIS->getSlotIndexes();
314 for (size_t I = 0, E = Intervals.size(); I < E; ++I) {
315 LiveInterval &LI = *Intervals[I];
316 Register Reg = LI.reg();
317
319
320 // Try to establish a single subregister which covers all uses.
321 // Note: this is assuming the selected subregister will only be
322 // used for fixing up live intervals issues created by this pass.
323 LaneBitmask UsedMask, UnusedMask;
324 for (LiveInterval::SubRange &SR : LI.subranges())
325 UsedMask |= SR.LaneMask;
326 SmallVector<unsigned> SubRegIdxs;
327 RegState Flags = {};
328 unsigned SubReg = 0;
329 // TODO: Handle SubRegIdxs.size() > 1
330 if (TRI.getCoveringSubRegIndexes(MRI->getRegClass(Reg), UsedMask,
331 SubRegIdxs) &&
332 SubRegIdxs.size() == 1) {
333 SubReg = SubRegIdxs.front();
334 Flags = RegState::Undef;
335 } else {
336 UnusedMask = MRI->getMaxLaneMaskForVReg(Reg) & ~UsedMask;
337 }
338
339 // There must be a def (or live-in) before every use. Splitting vregs may
340 // violate this principle as the splitted vreg may not have a definition on
341 // every path. Fix this by creating IMPLICIT_DEF instruction as necessary.
342 bool NeedsUnusedSubrange = UnusedMask.any();
343 for (const LiveInterval::SubRange &SR : LI.subranges()) {
344 // Search for "PHI" value numbers in the subranges. We must find a live
345 // value in each predecessor block, add an IMPLICIT_DEF where it is
346 // missing.
347 for (unsigned I = 0; I < SR.valnos.size(); ++I) {
348 const VNInfo &VNI = *SR.valnos[I];
349 if (VNI.isUnused() || !VNI.isPHIDef())
350 continue;
351
352 SlotIndex Def = VNI.def;
353 MachineBasicBlock &MBB = *Indexes.getMBBFromIndex(Def);
354 for (MachineBasicBlock *PredMBB : MBB.predecessors()) {
355 SlotIndex PredEnd = Indexes.getMBBEndIdx(PredMBB);
356 if (subRangeLiveAt(LI, PredEnd.getPrevSlot()))
357 continue;
358
361 const MCInstrDesc &MCDesc = TII->get(TargetOpcode::IMPLICIT_DEF);
362 MachineInstrBuilder ImpDef =
363 BuildMI(*PredMBB, InsertPos, DebugLoc(), MCDesc)
364 .addDef(Reg, Flags, SubReg);
365 SlotIndex DefIdx = LIS->InsertMachineInstrInMaps(*ImpDef);
366 SlotIndex RegDefIdx = DefIdx.getRegSlot();
367 for (LiveInterval::SubRange &SR : LI.subranges()) {
368 VNInfo *SRVNI = SR.getNextValue(RegDefIdx, Allocator);
369 SR.addSegment(LiveRange::Segment(RegDefIdx, PredEnd, SRVNI));
370 }
371 if (NeedsUnusedSubrange) {
372 LiveInterval::SubRange *SR =
373 LI.createSubRange(Allocator, UnusedMask);
374 SR->createDeadDef(RegDefIdx, Allocator);
375 // We only need to create a new subrange once, otherwise we end up
376 // with duplicate sub ranges for the unused lanes. The following
377 // iterations will attach their segment to this new subrange in the
378 // loop above.
379 NeedsUnusedSubrange = false;
380 }
381 }
382 }
383 }
384
385 for (MachineOperand &MO : MRI->reg_nodbg_operands(Reg)) {
386 if (!MO.isDef())
387 continue;
388 unsigned SubRegIdx = MO.getSubReg();
389 if (SubRegIdx == 0)
390 continue;
391 // After assigning the new vreg we may not have any other sublanes living
392 // in and out of the instruction anymore. We need to add new dead and
393 // undef flags in these cases.
394 if (!MO.isUndef()) {
395 SlotIndex Pos = LIS->getInstructionIndex(*MO.getParent());
396 if (!subRangeLiveAt(LI, Pos))
397 MO.setIsUndef();
398 }
399 if (!MO.isDead()) {
400 SlotIndex Pos = LIS->getInstructionIndex(*MO.getParent()).getDeadSlot();
401 if (!subRangeLiveAt(LI, Pos))
402 MO.setIsDead();
403 }
404 }
405
406 if (I == 0)
407 LI.clear();
409 // A def of a subregister may be a use of other register lanes. Replacing
410 // such a def with a def of a different register will eliminate the use,
411 // and may cause the recorded live range to be larger than the actual
412 // liveness in the program IR.
413 LIS->shrinkToUses(&LI);
414 }
415}
416
417PreservedAnalyses
420 auto &LIS = MFAM.getResult<LiveIntervalsAnalysis>(MF);
421 if (!RenameIndependentSubregs(&LIS).run(MF))
422 return PreservedAnalyses::all();
424 PA.preserveSet<CFGAnalyses>();
425 PA.preserve<LiveIntervalsAnalysis>();
426 PA.preserve<SlotIndexesAnalysis>();
427 return PA;
428}
429
430bool RenameIndependentSubregsLegacy::runOnMachineFunction(MachineFunction &MF) {
431 auto &LIS = getAnalysis<LiveIntervalsWrapperPass>().getLIS();
432 return RenameIndependentSubregs(&LIS).run(MF);
433}
434
435bool RenameIndependentSubregs::run(MachineFunction &MF) {
436 // Skip renaming if liveness of subregister is not tracked.
437 MRI = &MF.getRegInfo();
438 if (!MRI->subRegLivenessEnabled())
439 return false;
440
441 LLVM_DEBUG(dbgs() << "Renaming independent subregister live ranges in "
442 << MF.getName() << '\n');
443
445
446 // Iterate over all vregs. Note that we query getNumVirtRegs() the newly
447 // created vregs end up with higher numbers but do not need to be visited as
448 // there can't be any further splitting.
449 bool Changed = false;
450 for (size_t I = 0, E = MRI->getNumVirtRegs(); I < E; ++I) {
452 if (!LIS->hasInterval(Reg))
453 continue;
454 LiveInterval &LI = LIS->getInterval(Reg);
455 if (!LI.hasSubRanges())
456 continue;
457
458 Changed |= renameComponents(LI);
459 }
460
461 return Changed;
462}
MachineBasicBlock & MBB
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define DEBUG_TYPE
const HexagonInstrInfo * TII
IRTranslator LLVM IR MI
This file contains helper functions to modify live ranges.
#define I(x, y, z)
Definition MD5.cpp:57
Register Reg
Register const TargetRegisterInfo * TRI
Promote Memory to Register
Definition Mem2Reg.cpp:110
if(PassOpts->AAPipeline)
#define INITIALIZE_PASS_DEPENDENCY(depName)
Definition PassSupport.h:42
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition PassSupport.h:44
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Definition PassSupport.h:39
Basic Register Allocator
static bool subRangeLiveAt(const LiveInterval &LI, SlotIndex Pos)
#define LLVM_DEBUG(...)
Definition Debug.h:119
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
LLVM_ABI void setPreservesCFG()
This function should be called by the pass, iff they do not:
Definition Pass.cpp:275
Represents analyses that only rely on functions' control flow.
Definition Analysis.h:73
ConnectedVNInfoEqClasses - Helper class that can divide VNInfos in a LiveInterval into equivalence cl...
LLVM_ABI unsigned Classify(const LiveRange &LR)
Classify the values in LR into connected components.
const HexagonRegisterInfo & getRegisterInfo() const
LLVM_ABI void compress()
compress - Compress equivalence classes by numbering them 0 .
unsigned getNumClasses() const
getNumClasses - Return the number of equivalence classes after compress() was called.
LLVM_ABI unsigned join(unsigned a, unsigned b)
Join the equivalence classes of a and b.
LLVM_ABI void grow(unsigned N)
grow - Increase capacity to hold 0 .
A live range for subregisters.
LiveInterval - This class represents the liveness of a register, or stack slot.
LLVM_ABI void removeEmptySubRanges()
Removes all subranges without any segments (subranges without segments are not considered valid and s...
Register reg() const
bool hasSubRanges() const
Returns true if subregister liveness information is available.
iterator_range< subrange_iterator > subranges()
SubRange * createSubRange(BumpPtrAllocator &Allocator, LaneBitmask LaneMask)
Creates a new empty subregister live range.
bool hasInterval(Register Reg) const
SlotIndex InsertMachineInstrInMaps(MachineInstr &MI)
SlotIndexes * getSlotIndexes() const
SlotIndex getInstructionIndex(const MachineInstr &Instr) const
Returns the base index of the given instruction.
VNInfo::Allocator & getVNInfoAllocator()
LiveInterval & getInterval(Register Reg)
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.
LLVM_ABI iterator addSegment(Segment S)
Add the specified Segment to this range, merging segments as appropriate.
bool liveAt(SlotIndex index) const
LLVM_ABI VNInfo * createDeadDef(SlotIndex Def, VNInfo::Allocator &VNIAlloc)
createDeadDef - Make sure the range has a value defined at Def.
VNInfoList valnos
VNInfo * getNextValue(SlotIndex Def, VNInfo::Allocator &VNInfoAllocator)
getNextValue - Create a new value number and return it.
VNInfo * getVNInfoAt(SlotIndex Idx) const
getVNInfoAt - Return the VNInfo that is live at Idx, or NULL.
iterator_range< pred_iterator > predecessors()
MachineInstrBundleIterator< MachineInstr > iterator
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
const MachineInstrBuilder & addDef(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a virtual register definition operand.
unsigned getSubReg() const
LLVM_ABI unsigned getOperandNo() const
Returns the index of this operand in the instruction that it belongs to.
bool readsReg() const
readsReg - Returns true if this operand reads the previous value of its register.
void setIsDead(bool Val=true)
LLVM_ABI void setReg(Register Reg)
Change the register this operand corresponds to.
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
void setIsUndef(bool Val=true)
bool isEarlyClobber() const
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
reg_nodbg_iterator reg_nodbg_begin(Register RegNo) const
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
static reg_nodbg_iterator reg_nodbg_end()
const TargetRegisterInfo * getTargetRegisterInfo() const
LLVM_ABI LaneBitmask getMaxLaneMaskForVReg(Register Reg) const
Returns a mask covering all bits that can appear in lane masks of subregisters of the virtual registe...
iterator_range< reg_nodbg_iterator > reg_nodbg_operands(Register Reg) const
unsigned getNumVirtRegs() const
getNumVirtRegs - Return the number of virtual registers created.
defusechain_iterator< true, true, true, true, false > reg_nodbg_iterator
reg_nodbg_iterator/reg_nodbg_begin/reg_nodbg_end - Walk all defs and uses of the specified register,...
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition Analysis.h:118
Wrapper class representing virtual and physical registers.
Definition Register.h:20
static Register index2VirtReg(unsigned Index)
Convert a 0-based index to a virtual register number.
Definition Register.h:72
LLVM_ABI PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
SlotIndex - An opaque wrapper around machine indexes.
Definition SlotIndexes.h:66
SlotIndex getDeadSlot() const
Returns the dead def kill slot for the current instruction.
SlotIndex getBaseIndex() const
Returns the base index for associated with this index.
SlotIndex getPrevSlot() const
Returns the previous slot in the index list.
SlotIndex getRegSlot(bool EC=false) const
Returns the register use/def slot in the current instruction for a normal or early-clobber def.
LLVM_ABI Result run(MachineFunction &MF, MachineFunctionAnalysisManager &)
MachineBasicBlock * getMBBFromIndex(SlotIndex index) const
Returns the basic block which the given index falls in.
SlotIndex getMBBEndIdx(unsigned Num) const
Returns the index past the last valid index in the given basic block.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void reserve(size_type N)
void resize(size_type N)
void push_back(const T &Elt)
pointer data()
Return a pointer to the vector's buffer, even if empty().
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
TargetInstrInfo - Interface to description of machine instruction set.
virtual const TargetInstrInfo * getInstrInfo() const
bool isUnused() const
Returns true if this value is unused.
SlotIndex def
The index of the defining instruction.
bool isPHIDef() const
Returns true if this value is defined by a PHI instruction (or was, PHI instructions may have been el...
Changed
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
NodeAddr< DefNode * > Def
Definition RDFGraph.h:384
This is an optimization pass for GlobalISel generic memory operations.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
RegState
Flags to represent properties of register accesses.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.
static void DistributeRange(LiveRangeT &LR, LiveRangeT *SplitLRs[], EqClassesT VNIClasses)
Helper function that distributes live range value numbers and the corresponding segments of a primary...
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:209
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
MachineBasicBlock::iterator findPHICopyInsertPoint(MachineBasicBlock *MBB, MachineBasicBlock *SuccMBB, Register SrcReg)
findPHICopyInsertPoint - Find a safe place in MBB to insert a copy from SrcReg when following the CFG...
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Definition Allocator.h:390
LLVM_ABI char & RenameIndependentSubregsID
This pass detects subregister lanes in a virtual register that are used independently of other lanes ...
LLVM_ABI Printable printReg(Register Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
MCRegisterClass TargetRegisterClass
Definition FastISel.h:58
constexpr bool any() const
Definition LaneBitmask.h:53