Thanks to visit codestin.com
Credit goes to llvm.org

LLVM 22.0.0git
LiveRangeEdit.cpp
Go to the documentation of this file.
1//===-- LiveRangeEdit.cpp - Basic tools for editing a register live range -===//
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// The LiveRangeEdit class represents changes done to a virtual register when it
10// is spilled or split.
11//===----------------------------------------------------------------------===//
12
14#include "llvm/ADT/Statistic.h"
20#include "llvm/Support/Debug.h"
22
23using namespace llvm;
24
25#define DEBUG_TYPE "regalloc"
26
27STATISTIC(NumDCEDeleted, "Number of instructions deleted by DCE");
28STATISTIC(NumDCEFoldedLoads, "Number of single use loads folded after DCE");
29STATISTIC(NumFracRanges, "Number of live ranges fractured by DCE");
30STATISTIC(NumReMaterialization, "Number of instructions rematerialized");
31
32void LiveRangeEdit::Delegate::anchor() { }
33
34LiveInterval &LiveRangeEdit::createEmptyIntervalFrom(Register OldReg,
35 bool createSubRanges) {
36 Register VReg = MRI.cloneVirtualRegister(OldReg);
37 if (VRM)
38 VRM->setIsSplitFromReg(VReg, VRM->getOriginal(OldReg));
39
40 LiveInterval &LI = LIS.createEmptyInterval(VReg);
41 if (Parent && !Parent->isSpillable())
43 if (createSubRanges) {
44 // Create empty subranges if the OldReg's interval has them. Do not create
45 // the main range here---it will be constructed later after the subranges
46 // have been finalized.
47 LiveInterval &OldLI = LIS.getInterval(OldReg);
48 VNInfo::Allocator &Alloc = LIS.getVNInfoAllocator();
49 for (LiveInterval::SubRange &S : OldLI.subranges())
50 LI.createSubRange(Alloc, S.LaneMask);
51 }
52 return LI;
53}
54
56 Register VReg = MRI.cloneVirtualRegister(OldReg);
57 if (VRM) {
58 VRM->setIsSplitFromReg(VReg, VRM->getOriginal(OldReg));
59 }
60 // FIXME: Getting the interval here actually computes it.
61 // In theory, this may not be what we want, but in practice
62 // the createEmptyIntervalFrom API is used when this is not
63 // the case. Generally speaking we just want to annotate the
64 // LiveInterval when it gets created but we cannot do that at
65 // the moment.
66 if (Parent && !Parent->isSpillable())
67 LIS.getInterval(VReg).markNotSpillable();
68 return VReg;
69}
70
71void LiveRangeEdit::scanRemattable() {
72 for (VNInfo *VNI : getParent().valnos) {
73 if (VNI->isUnused())
74 continue;
75 Register Original = VRM->getOriginal(getReg());
76 LiveInterval &OrigLI = LIS.getInterval(Original);
77 VNInfo *OrigVNI = OrigLI.getVNInfoAt(VNI->def);
78 if (!OrigVNI)
79 continue;
81 if (!DefMI)
82 continue;
83 if (TII.isTriviallyReMaterializable(*DefMI))
84 Remattable.insert(OrigVNI);
85 }
86 ScannedRemattable = true;
87}
88
90 if (!ScannedRemattable)
91 scanRemattable();
92 return !Remattable.empty();
93}
94
95/// allUsesAvailableAt - Return true if all registers used by OrigMI at
96/// OrigIdx are also available with the same value at UseIdx.
98 SlotIndex OrigIdx,
99 SlotIndex UseIdx) const {
100 OrigIdx = OrigIdx.getRegSlot(true);
101 UseIdx = std::max(UseIdx, UseIdx.getRegSlot(true));
102 for (const MachineOperand &MO : OrigMI->operands()) {
103 if (!MO.isReg() || !MO.getReg() || !MO.readsReg())
104 continue;
105
106 // We can't remat physreg uses, unless it is a constant or target wants
107 // to ignore this use.
108 if (MO.getReg().isPhysical()) {
109 if (MRI.isConstantPhysReg(MO.getReg()) || TII.isIgnorableUse(MO))
110 continue;
111 return false;
112 }
113
114 LiveInterval &li = LIS.getInterval(MO.getReg());
115 const VNInfo *OVNI = li.getVNInfoAt(OrigIdx);
116 if (!OVNI)
117 continue;
118
119 // Don't allow rematerialization immediately after the original def.
120 // It would be incorrect if OrigMI redefines the register.
121 // See PR14098.
122 if (SlotIndex::isSameInstr(OrigIdx, UseIdx))
123 return false;
124
125 if (OVNI != li.getVNInfoAt(UseIdx))
126 return false;
127
128 // Check that subrange is live at UseIdx.
129 if (li.hasSubRanges()) {
130 const TargetRegisterInfo *TRI = MRI.getTargetRegisterInfo();
131 unsigned SubReg = MO.getSubReg();
132 LaneBitmask LM = SubReg ? TRI->getSubRegIndexLaneMask(SubReg)
133 : MRI.getMaxLaneMaskForVReg(MO.getReg());
134 for (LiveInterval::SubRange &SR : li.subranges()) {
135 if ((SR.LaneMask & LM).none())
136 continue;
137 if (!SR.liveAt(UseIdx))
138 return false;
139 // Early exit if all used lanes are checked. No need to continue.
140 LM &= ~SR.LaneMask;
141 if (LM.none())
142 break;
143 }
144 }
145 }
146 return true;
147}
148
150 SlotIndex UseIdx) {
151 assert(ScannedRemattable && "Call anyRematerializable first");
152
153 // Use scanRemattable info.
154 if (!Remattable.count(OrigVNI))
155 return false;
156
157 // No defining instruction provided.
158 SlotIndex DefIdx;
159 assert(RM.OrigMI && "No defining instruction for remattable value");
160 DefIdx = LIS.getInstructionIndex(*RM.OrigMI);
161
162 // Verify that all used registers are available with the same values.
163 if (!allUsesAvailableAt(RM.OrigMI, DefIdx, UseIdx))
164 return false;
165
166 return true;
167}
168
171 Register DestReg, const Remat &RM,
172 const TargetRegisterInfo &tri,
173 bool Late, unsigned SubIdx,
174 MachineInstr *ReplaceIndexMI) {
175 assert(RM.OrigMI && "Invalid remat");
176 TII.reMaterialize(MBB, MI, DestReg, SubIdx, *RM.OrigMI, tri);
177 // DestReg of the cloned instruction cannot be Dead. Set isDead of DestReg
178 // to false anyway in case the isDead flag of RM.OrigMI's dest register
179 // is true.
180 (*--MI).clearRegisterDeads(DestReg);
181 Rematted.insert(RM.ParentVNI);
182 ++NumReMaterialization;
183
184 bool EarlyClobber = MI->getOperand(0).isEarlyClobber();
185 if (ReplaceIndexMI)
186 return LIS.ReplaceMachineInstrInMaps(*ReplaceIndexMI, *MI)
187 .getRegSlot(EarlyClobber);
188 return LIS.getSlotIndexes()->insertMachineInstrInMaps(*MI, Late).getRegSlot(
189 EarlyClobber);
190}
191
193 if (TheDelegate && TheDelegate->LRE_CanEraseVirtReg(Reg))
194 LIS.removeInterval(Reg);
195}
196
197bool LiveRangeEdit::foldAsLoad(LiveInterval *LI,
199 MachineInstr *DefMI = nullptr, *UseMI = nullptr;
200
201 // Check that there is a single def and a single use.
202 for (MachineOperand &MO : MRI.reg_nodbg_operands(LI->reg())) {
203 MachineInstr *MI = MO.getParent();
204 if (MO.isDef()) {
205 if (DefMI && DefMI != MI)
206 return false;
207 if (!MI->canFoldAsLoad())
208 return false;
209 DefMI = MI;
210 } else if (!MO.isUndef()) {
211 if (UseMI && UseMI != MI)
212 return false;
213 // FIXME: Targets don't know how to fold subreg uses.
214 if (MO.getSubReg())
215 return false;
216 UseMI = MI;
217 }
218 }
219 if (!DefMI || !UseMI)
220 return false;
221
222 // Since we're moving the DefMI load, make sure we're not extending any live
223 // ranges.
224 if (!allUsesAvailableAt(DefMI, LIS.getInstructionIndex(*DefMI),
225 LIS.getInstructionIndex(*UseMI)))
226 return false;
227
228 // We also need to make sure it is safe to move the load.
229 // Assume there are stores between DefMI and UseMI.
230 bool SawStore = true;
231 if (!DefMI->isSafeToMove(SawStore))
232 return false;
233
234 LLVM_DEBUG(dbgs() << "Try to fold single def: " << *DefMI
235 << " into single use: " << *UseMI);
236
237 SmallVector<unsigned, 8> Ops;
238 if (UseMI->readsWritesVirtualRegister(LI->reg(), &Ops).second)
239 return false;
240
241 MachineInstr *FoldMI = TII.foldMemoryOperand(*UseMI, Ops, *DefMI, &LIS);
242 if (!FoldMI)
243 return false;
244 LLVM_DEBUG(dbgs() << " folded: " << *FoldMI);
245 LIS.ReplaceMachineInstrInMaps(*UseMI, *FoldMI);
246 // Update the call info.
250 DefMI->addRegisterDead(LI->reg(), nullptr);
251 Dead.push_back(DefMI);
252 ++NumDCEFoldedLoads;
253 return true;
254}
255
256bool LiveRangeEdit::useIsKill(const LiveInterval &LI,
257 const MachineOperand &MO) const {
258 const MachineInstr &MI = *MO.getParent();
259 SlotIndex Idx = LIS.getInstructionIndex(MI).getRegSlot();
260 if (LI.Query(Idx).isKill())
261 return true;
262 const TargetRegisterInfo &TRI = *MRI.getTargetRegisterInfo();
263 unsigned SubReg = MO.getSubReg();
264 LaneBitmask LaneMask = TRI.getSubRegIndexLaneMask(SubReg);
265 for (const LiveInterval::SubRange &S : LI.subranges()) {
266 if ((S.LaneMask & LaneMask).any() && S.Query(Idx).isKill())
267 return true;
268 }
269 return false;
270}
271
272/// Find all live intervals that need to shrink, then remove the instruction.
273void LiveRangeEdit::eliminateDeadDef(MachineInstr *MI, ToShrinkSet &ToShrink) {
274 assert(MI->allDefsAreDead() && "Def isn't really dead");
275 SlotIndex Idx = LIS.getInstructionIndex(*MI).getRegSlot();
276
277 // Never delete a bundled instruction.
278 if (MI->isBundled()) {
279 // TODO: Handle deleting copy bundles
280 LLVM_DEBUG(dbgs() << "Won't delete dead bundled inst: " << Idx << '\t'
281 << *MI);
282 return;
283 }
284
285 // Never delete inline asm.
286 if (MI->isInlineAsm()) {
287 LLVM_DEBUG(dbgs() << "Won't delete: " << Idx << '\t' << *MI);
288 return;
289 }
290
291 // Use the same criteria as DeadMachineInstructionElim.
292 bool SawStore = false;
293 if (!MI->isSafeToMove(SawStore)) {
294 LLVM_DEBUG(dbgs() << "Can't delete: " << Idx << '\t' << *MI);
295 return;
296 }
297
298 LLVM_DEBUG(dbgs() << "Deleting dead def " << Idx << '\t' << *MI);
299
300 // Collect virtual registers to be erased after MI is gone.
301 SmallVector<Register, 8> RegsToErase;
302 bool ReadsPhysRegs = false;
303 bool isOrigDef = false;
304 Register Dest;
305 unsigned DestSubReg;
306 // Only optimize rematerialize case when the instruction has one def, since
307 // otherwise we could leave some dead defs in the code. This case is
308 // extremely rare.
309 if (VRM && MI->getOperand(0).isReg() && MI->getOperand(0).isDef() &&
310 MI->getDesc().getNumDefs() == 1) {
311 Dest = MI->getOperand(0).getReg();
312 DestSubReg = MI->getOperand(0).getSubReg();
313 Register Original = VRM->getOriginal(Dest);
314 LiveInterval &OrigLI = LIS.getInterval(Original);
315 VNInfo *OrigVNI = OrigLI.getVNInfoAt(Idx);
316 // The original live-range may have been shrunk to
317 // an empty live-range. It happens when it is dead, but
318 // we still keep it around to be able to rematerialize
319 // other values that depend on it.
320 if (OrigVNI)
321 isOrigDef = SlotIndex::isSameInstr(OrigVNI->def, Idx);
322 }
323
324 bool HasLiveVRegUses = false;
325
326 // Check for live intervals that may shrink
327 for (const MachineOperand &MO : MI->operands()) {
328 if (!MO.isReg())
329 continue;
330 Register Reg = MO.getReg();
331 if (!Reg.isVirtual()) {
332 // Check if MI reads any unreserved physregs.
333 if (Reg && MO.readsReg() && !MRI.isReserved(Reg))
334 ReadsPhysRegs = true;
335 else if (MO.isDef())
336 LIS.removePhysRegDefAt(Reg.asMCReg(), Idx);
337 continue;
338 }
339 LiveInterval &LI = LIS.getInterval(Reg);
340
341 // Shrink read registers, unless it is likely to be expensive and
342 // unlikely to change anything. We typically don't want to shrink the
343 // PIC base register that has lots of uses everywhere.
344 // Always shrink COPY uses that probably come from live range splitting.
345 if ((MI->readsVirtualRegister(Reg) &&
346 (MO.isDef() || TII.isCopyInstr(*MI))) ||
347 (MO.readsReg() && (MRI.hasOneNonDBGUse(Reg) || useIsKill(LI, MO))))
348 ToShrink.insert(&LI);
349 else if (MO.readsReg())
350 HasLiveVRegUses = true;
351
352 // Remove defined value.
353 if (MO.isDef()) {
354 if (TheDelegate && LI.getVNInfoAt(Idx) != nullptr)
355 TheDelegate->LRE_WillShrinkVirtReg(LI.reg());
356 LIS.removeVRegDefAt(LI, Idx);
357 if (LI.empty())
358 RegsToErase.push_back(Reg);
359 }
360 }
361
362 // Currently, we don't support DCE of physreg live ranges. If MI reads
363 // any unreserved physregs, don't erase the instruction, but turn it into
364 // a KILL instead. This way, the physreg live ranges don't end up
365 // dangling.
366 // FIXME: It would be better to have something like shrinkToUses() for
367 // physregs. That could potentially enable more DCE and it would free up
368 // the physreg. It would not happen often, though.
369 if (ReadsPhysRegs) {
370 MI->setDesc(TII.get(TargetOpcode::KILL));
371 // Remove all operands that aren't physregs.
372 for (unsigned i = MI->getNumOperands(); i; --i) {
373 const MachineOperand &MO = MI->getOperand(i-1);
374 if (MO.isReg() && MO.getReg().isPhysical())
375 continue;
376 MI->removeOperand(i-1);
377 }
378 MI->dropMemRefs(*MI->getMF());
379 LLVM_DEBUG(dbgs() << "Converted physregs to:\t" << *MI);
380 } else {
381 // If the dest of MI is an original reg and MI is reMaterializable,
382 // don't delete the inst. Replace the dest with a new reg, and keep
383 // the inst for remat of other siblings. The inst is saved in
384 // LiveRangeEdit::DeadRemats and will be deleted after all the
385 // allocations of the func are done.
386 // However, immediately delete instructions which have unshrunk virtual
387 // register uses. That may provoke RA to split an interval at the KILL
388 // and later result in an invalid live segment end.
389 if (isOrigDef && DeadRemats && !HasLiveVRegUses &&
390 TII.isTriviallyReMaterializable(*MI)) {
391 LiveInterval &NewLI = createEmptyIntervalFrom(Dest, false);
392 VNInfo::Allocator &Alloc = LIS.getVNInfoAllocator();
393 VNInfo *VNI = NewLI.getNextValue(Idx, Alloc);
394 NewLI.addSegment(LiveInterval::Segment(Idx, Idx.getDeadSlot(), VNI));
395
396 if (DestSubReg) {
397 const TargetRegisterInfo *TRI = MRI.getTargetRegisterInfo();
398 auto *SR = NewLI.createSubRange(
399 Alloc, TRI->getSubRegIndexLaneMask(DestSubReg));
400 SR->addSegment(LiveInterval::Segment(Idx, Idx.getDeadSlot(),
401 SR->getNextValue(Idx, Alloc)));
402 }
403
404 pop_back();
405 DeadRemats->insert(MI);
406 const TargetRegisterInfo &TRI = *MRI.getTargetRegisterInfo();
407 MI->substituteRegister(Dest, NewLI.reg(), 0, TRI);
408 assert(MI->registerDefIsDead(NewLI.reg(), &TRI));
409 } else {
410 if (TheDelegate)
411 TheDelegate->LRE_WillEraseInstruction(MI);
412 LIS.RemoveMachineInstrFromMaps(*MI);
413 MI->eraseFromParent();
414 ++NumDCEDeleted;
415 }
416 }
417
418 // Erase any virtregs that are now empty and unused. There may be <undef>
419 // uses around. Keep the empty live range in that case.
420 for (Register Reg : RegsToErase) {
421 if (LIS.hasInterval(Reg) && MRI.reg_nodbg_empty(Reg)) {
422 ToShrink.remove(&LIS.getInterval(Reg));
424 }
425 }
426}
427
429 ArrayRef<Register> RegsBeingSpilled) {
430 ToShrinkSet ToShrink;
431
432 for (;;) {
433 // Erase all dead defs.
434 while (!Dead.empty())
435 eliminateDeadDef(Dead.pop_back_val(), ToShrink);
436
437 if (ToShrink.empty())
438 break;
439
440 // Shrink just one live interval. Then delete new dead defs.
441 LiveInterval *LI = ToShrink.pop_back_val();
442 if (foldAsLoad(LI, Dead))
443 continue;
444 Register VReg = LI->reg();
445 if (TheDelegate)
446 TheDelegate->LRE_WillShrinkVirtReg(VReg);
447 if (!LIS.shrinkToUses(LI, &Dead))
448 continue;
449
450 // Don't create new intervals for a register being spilled.
451 // The new intervals would have to be spilled anyway so its not worth it.
452 // Also they currently aren't spilled so creating them and not spilling
453 // them results in incorrect code.
454 if (llvm::is_contained(RegsBeingSpilled, VReg))
455 continue;
456
457 // LI may have been separated, create new intervals.
458 LI->RenumberValues();
460 LIS.splitSeparateComponents(*LI, SplitLIs);
461 if (!SplitLIs.empty())
462 ++NumFracRanges;
463
464 Register Original = VRM ? VRM->getOriginal(VReg) : Register();
465 for (const LiveInterval *SplitLI : SplitLIs) {
466 // If LI is an original interval that hasn't been split yet, make the new
467 // intervals their own originals instead of referring to LI. The original
468 // interval must contain all the split products, and LI doesn't.
469 if (Original != VReg && Original != 0)
470 VRM->setIsSplitFromReg(SplitLI->reg(), Original);
471 if (TheDelegate)
472 TheDelegate->LRE_DidCloneVirtReg(SplitLI->reg(), VReg);
473 }
474 }
475}
476
477// Keep track of new virtual registers created via
478// MachineRegisterInfo::createVirtualRegister.
479void
480LiveRangeEdit::MRI_NoteNewVirtualRegister(Register VReg) {
481 if (VRM)
482 VRM->grow();
483
484 NewRegs.push_back(VReg);
485}
486
488 VirtRegAuxInfo &VRAI) {
489 for (unsigned I = 0, Size = size(); I < Size; ++I) {
490 LiveInterval &LI = LIS.getInterval(get(I));
491 if (MRI.recomputeRegClass(LI.reg()))
492 LLVM_DEBUG({
494 dbgs() << "Inflated " << printReg(LI.reg()) << " to "
495 << TRI->getRegClassName(MRI.getRegClass(LI.reg())) << '\n';
496 });
498 }
499}
unsigned SubReg
unsigned const MachineRegisterInfo * MRI
MachineInstrBuilder & UseMI
MachineInstrBuilder MachineInstrBuilder & DefMI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock & MBB
const HexagonInstrInfo * TII
IRTranslator LLVM IR MI
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
#define I(x, y, z)
Definition MD5.cpp:58
Register Reg
Register const TargetRegisterInfo * TRI
Promote Memory to Register
Definition Mem2Reg.cpp:110
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
Definition Statistic.h:171
#define LLVM_DEBUG(...)
Definition Debug.h:114
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:41
A live range for subregisters.
LiveInterval - This class represents the liveness of a register, or stack slot.
void markNotSpillable()
markNotSpillable - Mark interval as not spillable
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.
MachineInstr * getInstructionFromIndex(SlotIndex index) const
Returns the instruction associated with the given index.
LiveInterval & getInterval(Register Reg)
bool isKill() const
Return true if the live-in value is killed by this instruction.
void eraseVirtReg(Register Reg)
eraseVirtReg - Notify the delegate that Reg is no longer in use, and try to erase it from LIS.
unsigned size() const
bool canRematerializeAt(Remat &RM, VNInfo *OrigVNI, SlotIndex UseIdx)
canRematerializeAt - Determine if ParentVNI can be rematerialized at UseIdx.
Register get(unsigned idx) const
Register createFrom(Register OldReg)
createFrom - Create a new virtual register based on OldReg.
void calculateRegClassAndHint(MachineFunction &, VirtRegAuxInfo &)
calculateRegClassAndHint - Recompute register class and hint for each new register.
const LiveInterval & getParent() const
Register getReg() const
SlotIndex rematerializeAt(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, Register DestReg, const Remat &RM, const TargetRegisterInfo &, bool Late=false, unsigned SubIdx=0, MachineInstr *ReplaceIndexMI=nullptr)
rematerializeAt - Rematerialize RM.ParentVNI into DestReg by inserting an instruction into MBB before...
bool allUsesAvailableAt(const MachineInstr *OrigMI, SlotIndex OrigIdx, SlotIndex UseIdx) const
allUsesAvailableAt - Return true if all registers used by OrigMI at OrigIdx are also available with t...
void eliminateDeadDefs(SmallVectorImpl< MachineInstr * > &Dead, ArrayRef< Register > RegsBeingSpilled={})
eliminateDeadDefs - Try to delete machine instructions that are now dead (allDefsAreDead returns true...
void pop_back()
pop_back - It allows LiveRangeEdit users to drop new registers.
bool anyRematerializable()
anyRematerializable - Return true if any parent values may be rematerializable.
LLVM_ABI iterator addSegment(Segment S)
Add the specified Segment to this range, merging segments as appropriate.
bool empty() const
LLVM_ABI void RenumberValues()
RenumberValues - Renumber all values in order of appearance and remove unused values.
LiveQueryResult Query(SlotIndex Idx) const
Query Liveness at Idx.
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.
MachineInstrBundleIterator< MachineInstr > iterator
void moveAdditionalCallInfo(const MachineInstr *Old, const MachineInstr *New)
Move the call site info from Old to \New call site info.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Representation of each machine instruction.
LLVM_ABI std::pair< bool, bool > readsWritesVirtualRegister(Register Reg, SmallVectorImpl< unsigned > *Ops=nullptr) const
Return a pair of bools (reads, writes) indicating if this instruction reads or writes Reg.
LLVM_ABI bool isSafeToMove(bool &SawStore) const
Return true if it is safe to move this instruction.
mop_range operands()
LLVM_ABI const MachineFunction * getMF() const
Return the function that contains the basic block that this instruction belongs to.
LLVM_ABI void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
LLVM_ABI bool shouldUpdateAdditionalCallInfo() const
Return true if copying, moving, or erasing this instruction requires updating additional call info (s...
LLVM_ABI bool addRegisterDead(Register Reg, const TargetRegisterInfo *RegInfo, bool AddIfNotFound=false)
We have determined MI defined a register without a use.
MachineOperand class - Representation of each machine instruction operand.
unsigned getSubReg() const
bool readsReg() const
readsReg - Returns true if this operand reads the previous value of its register.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
Register getReg() const
getReg - Returns the register number.
Wrapper class representing virtual and physical registers.
Definition Register.h:19
MCRegister asMCReg() const
Utility to check-convert this value to a MCRegister.
Definition Register.h:102
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
Definition Register.h:74
constexpr bool isPhysical() const
Return true if the specified register number is in the physical register namespace.
Definition Register.h:78
bool empty() const
Determine if the SetVector is empty or not.
Definition SetVector.h:99
value_type pop_back_val()
Definition SetVector.h:296
SlotIndex - An opaque wrapper around machine indexes.
Definition SlotIndexes.h:66
static bool isSameInstr(SlotIndex A, SlotIndex B)
isSameInstr - Return true if A and B refer to the same instruction.
SlotIndex getDeadSlot() const
Returns the dead def kill slot for the current instruction.
SlotIndex getRegSlot(bool EC=false) const
Returns the register use/def slot in the current instruction for a normal or early-clobber def.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual const TargetRegisterInfo * getRegisterInfo() const =0
Return the target's register information.
VNInfo - Value Number Information.
BumpPtrAllocator Allocator
SlotIndex def
The index of the defining instruction.
Calculate auxiliary information for a virtual register such as its spill weight and allocation hint.
void calculateSpillWeightAndHint(LiveInterval &LI)
(re)compute li's spill weight and allocation hint.
Register getOriginal(Register VirtReg) const
getOriginal - Return the original virtual register that VirtReg descends from through splitting.
Definition VirtRegMap.h:155
LLVM_ABI void grow()
@ Dead
Unused definition.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:207
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Definition STLExtras.h:1877
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.
constexpr bool none() const
Definition LaneBitmask.h:52
Remat - Information needed to rematerialize at a specific location.