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();
113 }
114};
115
116} // end anonymous namespace
117
118char RenameIndependentSubregsLegacy::ID;
119
120char &llvm::RenameIndependentSubregsID = RenameIndependentSubregsLegacy::ID;
121
122INITIALIZE_PASS_BEGIN(RenameIndependentSubregsLegacy, DEBUG_TYPE,
123 "Rename Independent Subregisters", false, false)
126INITIALIZE_PASS_END(RenameIndependentSubregsLegacy, DEBUG_TYPE,
127 "Rename Independent Subregisters", false, false)
128
129bool RenameIndependentSubregs::renameComponents(LiveInterval &LI) const {
130 // Shortcut: We cannot have split components with a single definition.
131 if (LI.valnos.size() < 2)
132 return false;
133
134 SmallVector<SubRangeInfo, 4> SubRangeInfos;
135 IntEqClasses Classes;
136 if (!findComponents(Classes, SubRangeInfos, LI))
137 return false;
138
139 // Create a new VReg for each class.
140 Register Reg = LI.reg();
141 const TargetRegisterClass *RegClass = MRI->getRegClass(Reg);
143 Intervals.push_back(&LI);
144 LLVM_DEBUG(dbgs() << printReg(Reg) << ": Found " << Classes.getNumClasses()
145 << " equivalence classes.\n");
146 LLVM_DEBUG(dbgs() << printReg(Reg) << ": Splitting into newly created:");
147 for (unsigned I = 1, NumClasses = Classes.getNumClasses(); I < NumClasses;
148 ++I) {
149 Register NewVReg = MRI->createVirtualRegister(RegClass);
150 LiveInterval &NewLI = LIS->createEmptyInterval(NewVReg);
151 Intervals.push_back(&NewLI);
152 LLVM_DEBUG(dbgs() << ' ' << printReg(NewVReg));
153 }
154 LLVM_DEBUG(dbgs() << '\n');
155
156 rewriteOperands(Classes, SubRangeInfos, Intervals);
157 distribute(Classes, SubRangeInfos, Intervals);
158 computeMainRangesFixFlags(Classes, SubRangeInfos, Intervals);
159 return true;
160}
161
162bool RenameIndependentSubregs::findComponents(IntEqClasses &Classes,
164 LiveInterval &LI) const {
165 // First step: Create connected components for the VNInfos inside the
166 // subranges and count the global number of such components.
167 unsigned NumComponents = 0;
168 for (LiveInterval::SubRange &SR : LI.subranges()) {
169 SubRangeInfos.push_back(SubRangeInfo(*LIS, SR, NumComponents));
170 ConnectedVNInfoEqClasses &ConEQ = SubRangeInfos.back().ConEQ;
171
172 unsigned NumSubComponents = ConEQ.Classify(SR);
173 NumComponents += NumSubComponents;
174 }
175 // Shortcut: With only 1 subrange, the normal separate component tests are
176 // enough and we do not need to perform the union-find on the subregister
177 // segments.
178 if (SubRangeInfos.size() < 2)
179 return false;
180
181 // Next step: Build union-find structure over all subranges and merge classes
182 // across subranges when they are affected by the same MachineOperand.
183 const TargetRegisterInfo &TRI = *MRI->getTargetRegisterInfo();
184 Classes.grow(NumComponents);
185 Register Reg = LI.reg();
186 for (const MachineOperand &MO : MRI->reg_nodbg_operands(Reg)) {
187 if (!MO.isDef() && !MO.readsReg())
188 continue;
189 unsigned SubRegIdx = MO.getSubReg();
190 LaneBitmask LaneMask = TRI.getSubRegIndexLaneMask(SubRegIdx);
191 unsigned MergedID = ~0u;
192 for (RenameIndependentSubregs::SubRangeInfo &SRInfo : SubRangeInfos) {
193 const LiveInterval::SubRange &SR = *SRInfo.SR;
194 if ((SR.LaneMask & LaneMask).none())
195 continue;
196 SlotIndex Pos = LIS->getInstructionIndex(*MO.getParent());
197 Pos = MO.isDef() ? Pos.getRegSlot(MO.isEarlyClobber())
198 : Pos.getBaseIndex();
199 const VNInfo *VNI = SR.getVNInfoAt(Pos);
200 if (VNI == nullptr)
201 continue;
202
203 // Map to local representant ID.
204 unsigned LocalID = SRInfo.ConEQ.getEqClass(VNI);
205 // Global ID
206 unsigned ID = LocalID + SRInfo.Index;
207 // Merge other sets
208 MergedID = MergedID == ~0u ? ID : Classes.join(MergedID, ID);
209 }
210 }
211
212 // Early exit if we ended up with a single equivalence class.
213 Classes.compress();
214 unsigned NumClasses = Classes.getNumClasses();
215 return NumClasses > 1;
216}
217
218void RenameIndependentSubregs::rewriteOperands(const IntEqClasses &Classes,
219 const SmallVectorImpl<SubRangeInfo> &SubRangeInfos,
220 const SmallVectorImpl<LiveInterval*> &Intervals) const {
221 const TargetRegisterInfo &TRI = *MRI->getTargetRegisterInfo();
222 Register Reg = Intervals[0]->reg();
224 E = MRI->reg_nodbg_end(); I != E; ) {
225 MachineOperand &MO = *I++;
226 if (!MO.isDef() && !MO.readsReg())
227 continue;
228
229 auto *MI = MO.getParent();
230 SlotIndex Pos = LIS->getInstructionIndex(*MI);
231 Pos = MO.isDef() ? Pos.getRegSlot(MO.isEarlyClobber())
232 : Pos.getBaseIndex();
233 unsigned SubRegIdx = MO.getSubReg();
234 LaneBitmask LaneMask = TRI.getSubRegIndexLaneMask(SubRegIdx);
235
236 unsigned ID = ~0u;
237 for (const SubRangeInfo &SRInfo : SubRangeInfos) {
238 const LiveInterval::SubRange &SR = *SRInfo.SR;
239 if ((SR.LaneMask & LaneMask).none())
240 continue;
241 const VNInfo *VNI = SR.getVNInfoAt(Pos);
242 if (VNI == nullptr)
243 continue;
244
245 // Map to local representant ID.
246 unsigned LocalID = SRInfo.ConEQ.getEqClass(VNI);
247 // Global ID
248 ID = Classes[LocalID + SRInfo.Index];
249 break;
250 }
251
252 Register VReg = Intervals[ID]->reg();
253 MO.setReg(VReg);
254
255 if (MO.isTied() && Reg != VReg) {
256 /// Undef use operands are not tracked in the equivalence class,
257 /// but need to be updated if they are tied; take care to only
258 /// update the tied operand.
259 unsigned OperandNo = MO.getOperandNo();
260 unsigned TiedIdx = MI->findTiedOperandIdx(OperandNo);
261 MI->getOperand(TiedIdx).setReg(VReg);
262
263 // above substitution breaks the iterator, so restart.
264 I = MRI->reg_nodbg_begin(Reg);
265 }
266 }
267 // TODO: We could attempt to recompute new register classes while visiting
268 // the operands: Some of the split register may be fine with less constraint
269 // classes than the original vreg.
270}
271
272void RenameIndependentSubregs::distribute(const IntEqClasses &Classes,
273 const SmallVectorImpl<SubRangeInfo> &SubRangeInfos,
274 const SmallVectorImpl<LiveInterval*> &Intervals) const {
275 unsigned NumClasses = Classes.getNumClasses();
276 SmallVector<unsigned, 8> VNIMapping;
279 for (const SubRangeInfo &SRInfo : SubRangeInfos) {
280 LiveInterval::SubRange &SR = *SRInfo.SR;
281 unsigned NumValNos = SR.valnos.size();
282 VNIMapping.clear();
283 VNIMapping.reserve(NumValNos);
284 SubRanges.clear();
285 SubRanges.resize(NumClasses-1, nullptr);
286 for (unsigned I = 0; I < NumValNos; ++I) {
287 const VNInfo &VNI = *SR.valnos[I];
288 unsigned LocalID = SRInfo.ConEQ.getEqClass(&VNI);
289 unsigned ID = Classes[LocalID + SRInfo.Index];
290 VNIMapping.push_back(ID);
291 if (ID > 0 && SubRanges[ID-1] == nullptr)
292 SubRanges[ID-1] = Intervals[ID]->createSubRange(Allocator, SR.LaneMask);
293 }
294 DistributeRange(SR, SubRanges.data(), VNIMapping);
295 }
296}
297
298static bool subRangeLiveAt(const LiveInterval &LI, SlotIndex Pos) {
299 for (const LiveInterval::SubRange &SR : LI.subranges()) {
300 if (SR.liveAt(Pos))
301 return true;
302 }
303 return false;
304}
305
306void RenameIndependentSubregs::computeMainRangesFixFlags(
307 const IntEqClasses &Classes,
308 const SmallVectorImpl<SubRangeInfo> &SubRangeInfos,
309 const SmallVectorImpl<LiveInterval*> &Intervals) const {
310 const TargetRegisterInfo &TRI = TII->getRegisterInfo();
312 const SlotIndexes &Indexes = *LIS->getSlotIndexes();
313 for (size_t I = 0, E = Intervals.size(); I < E; ++I) {
314 LiveInterval &LI = *Intervals[I];
315 Register Reg = LI.reg();
316
318
319 // Try to establish a single subregister which covers all uses.
320 // Note: this is assuming the selected subregister will only be
321 // used for fixing up live intervals issues created by this pass.
322 LaneBitmask UsedMask, UnusedMask;
323 for (LiveInterval::SubRange &SR : LI.subranges())
324 UsedMask |= SR.LaneMask;
325 SmallVector<unsigned> SubRegIdxs;
326 RegState Flags = {};
327 unsigned SubReg = 0;
328 // TODO: Handle SubRegIdxs.size() > 1
329 if (TRI.getCoveringSubRegIndexes(MRI->getRegClass(Reg), UsedMask,
330 SubRegIdxs) &&
331 SubRegIdxs.size() == 1) {
332 SubReg = SubRegIdxs.front();
333 Flags = RegState::Undef;
334 } else {
335 UnusedMask = MRI->getMaxLaneMaskForVReg(Reg) & ~UsedMask;
336 }
337
338 // There must be a def (or live-in) before every use. Splitting vregs may
339 // violate this principle as the splitted vreg may not have a definition on
340 // every path. Fix this by creating IMPLICIT_DEF instruction as necessary.
341 bool NeedsUnusedSubrange = UnusedMask.any();
342 for (const LiveInterval::SubRange &SR : LI.subranges()) {
343 // Search for "PHI" value numbers in the subranges. We must find a live
344 // value in each predecessor block, add an IMPLICIT_DEF where it is
345 // missing.
346 for (unsigned I = 0; I < SR.valnos.size(); ++I) {
347 const VNInfo &VNI = *SR.valnos[I];
348 if (VNI.isUnused() || !VNI.isPHIDef())
349 continue;
350
351 SlotIndex Def = VNI.def;
352 MachineBasicBlock &MBB = *Indexes.getMBBFromIndex(Def);
353 for (MachineBasicBlock *PredMBB : MBB.predecessors()) {
354 SlotIndex PredEnd = Indexes.getMBBEndIdx(PredMBB);
355 if (subRangeLiveAt(LI, PredEnd.getPrevSlot()))
356 continue;
357
360 const MCInstrDesc &MCDesc = TII->get(TargetOpcode::IMPLICIT_DEF);
361 MachineInstrBuilder ImpDef =
362 BuildMI(*PredMBB, InsertPos, DebugLoc(), MCDesc)
363 .addDef(Reg, Flags, SubReg);
364 SlotIndex DefIdx = LIS->InsertMachineInstrInMaps(*ImpDef);
365 SlotIndex RegDefIdx = DefIdx.getRegSlot();
366 for (LiveInterval::SubRange &SR : LI.subranges()) {
367 VNInfo *SRVNI = SR.getNextValue(RegDefIdx, Allocator);
368 SR.addSegment(LiveRange::Segment(RegDefIdx, PredEnd, SRVNI));
369 }
370 if (NeedsUnusedSubrange) {
371 LiveInterval::SubRange *SR =
372 LI.createSubRange(Allocator, UnusedMask);
373 SR->createDeadDef(RegDefIdx, Allocator);
374 // We only need to create a new subrange once, otherwise we end up
375 // with duplicate sub ranges for the unused lanes. The following
376 // iterations will attach their segment to this new subrange in the
377 // loop above.
378 NeedsUnusedSubrange = false;
379 }
380 }
381 }
382 }
383
384 for (MachineOperand &MO : MRI->reg_nodbg_operands(Reg)) {
385 if (!MO.isDef())
386 continue;
387 unsigned SubRegIdx = MO.getSubReg();
388 if (SubRegIdx == 0)
389 continue;
390 // After assigning the new vreg we may not have any other sublanes living
391 // in and out of the instruction anymore. We need to add new dead and
392 // undef flags in these cases.
393 if (!MO.isUndef()) {
394 SlotIndex Pos = LIS->getInstructionIndex(*MO.getParent());
395 if (!subRangeLiveAt(LI, Pos))
396 MO.setIsUndef();
397 }
398 if (!MO.isDead()) {
399 SlotIndex Pos = LIS->getInstructionIndex(*MO.getParent()).getDeadSlot();
400 if (!subRangeLiveAt(LI, Pos))
401 MO.setIsDead();
402 }
403 }
404
405 if (I == 0)
406 LI.clear();
408 // A def of a subregister may be a use of other register lanes. Replacing
409 // such a def with a def of a different register will eliminate the use,
410 // and may cause the recorded live range to be larger than the actual
411 // liveness in the program IR.
412 LIS->shrinkToUses(&LI);
413 }
414}
415
416PreservedAnalyses
419 auto &LIS = MFAM.getResult<LiveIntervalsAnalysis>(MF);
420 if (!RenameIndependentSubregs(&LIS).run(MF))
421 return PreservedAnalyses::all();
423 PA.preserveSet<CFGAnalyses>();
424 PA.preserve<LiveIntervalsAnalysis>();
425 PA.preserve<SlotIndexesAnalysis>();
426 return PA;
427}
428
429bool RenameIndependentSubregsLegacy::runOnMachineFunction(MachineFunction &MF) {
430 auto &LIS = getAnalysis<LiveIntervalsWrapperPass>().getLIS();
431 return RenameIndependentSubregs(&LIS).run(MF);
432}
433
434bool RenameIndependentSubregs::run(MachineFunction &MF) {
435 // Skip renaming if liveness of subregister is not tracked.
436 MRI = &MF.getRegInfo();
437 if (!MRI->subRegLivenessEnabled())
438 return false;
439
440 LLVM_DEBUG(dbgs() << "Renaming independent subregister live ranges in "
441 << MF.getName() << '\n');
442
444
445 // Iterate over all vregs. Note that we query getNumVirtRegs() the newly
446 // created vregs end up with higher numbers but do not need to be visited as
447 // there can't be any further splitting.
448 bool Changed = false;
449 for (size_t I = 0, E = MRI->getNumVirtRegs(); I < E; ++I) {
451 if (!LIS->hasInterval(Reg))
452 continue;
453 LiveInterval &LI = LIS->getInterval(Reg);
454 if (!LI.hasSubRanges())
455 continue;
456
457 Changed |= renameComponents(LI);
458 }
459
460 return Changed;
461}
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
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