LLVM 23.0.0git
PHIElimination.cpp
Go to the documentation of this file.
1//===- PhiElimination.cpp - Eliminate PHI nodes by inserting copies -------===//
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// This pass eliminates machine instruction PHI nodes by inserting copy
10// instructions. This destroys SSA information, but is the desired input for
11// some register allocators.
12//
13//===----------------------------------------------------------------------===//
14
16#include "PHIEliminationUtils.h"
17#include "llvm/ADT/DenseMap.h"
19#include "llvm/ADT/Statistic.h"
43#include "llvm/Pass.h"
45#include "llvm/Support/Debug.h"
47#include <cassert>
48#include <iterator>
49#include <utility>
50
51using namespace llvm;
52
53#define DEBUG_TYPE "phi-node-elimination"
54
55static cl::opt<bool>
56 DisableEdgeSplitting("disable-phi-elim-edge-splitting", cl::init(false),
58 cl::desc("Disable critical edge splitting "
59 "during PHI elimination"));
60
61static cl::opt<bool>
62 SplitAllCriticalEdges("phi-elim-split-all-critical-edges", cl::init(false),
64 cl::desc("Split all critical edges during "
65 "PHI elimination"));
66
68 "no-phi-elim-live-out-early-exit", cl::init(false), cl::Hidden,
69 cl::desc("Do not use an early exit if isLiveOutPastPHIs returns true."));
70
71namespace {
72
73class PHIEliminationImpl {
74 MachineRegisterInfo *MRI = nullptr; // Machine register information
75 LiveVariables *LV = nullptr;
76 LiveIntervals *LIS = nullptr;
77 MachineLoopInfo *MLI = nullptr;
78 MachineDominatorTree *MDT = nullptr;
79 MachinePostDominatorTree *PDT = nullptr;
80 const MachineBranchProbabilityInfo *MBPI = nullptr;
81 MachineBlockFrequencyInfo *MBFI = nullptr;
82
83 /// EliminatePHINodes - Eliminate phi nodes by inserting copy instructions
84 /// in predecessor basic blocks.
85 bool EliminatePHINodes(MachineFunction &MF, MachineBasicBlock &MBB);
86
87 void LowerPHINode(MachineBasicBlock &MBB,
89 bool AllEdgesCritical);
90
91 /// analyzePHINodes - Gather information about the PHI nodes in
92 /// here. In particular, we want to map the number of uses of a virtual
93 /// register which is used in a PHI node. We map that to the BB the
94 /// vreg is coming from. This is used later to determine when the vreg
95 /// is killed in the BB.
96 void analyzePHINodes(const MachineFunction &MF);
97
98 /// Split critical edges where necessary for good coalescer performance.
99 bool SplitPHIEdges(MachineFunction &MF, MachineBasicBlock &MBB,
100 MachineLoopInfo *MLI,
101 std::vector<SparseBitVector<>> *LiveInSets,
103
104 // These functions are temporary abstractions around LiveVariables and
105 // LiveIntervals, so they can go away when LiveVariables does.
106 bool isLiveIn(Register Reg, const MachineBasicBlock *MBB);
107 bool isLiveOutPastPHIs(Register Reg, const MachineBasicBlock *MBB);
108
109 using BBVRegPair = std::pair<unsigned, Register>;
110 using VRegPHIUse = DenseMap<BBVRegPair, unsigned>;
111
112 // Count the number of non-undef PHI uses of each register in each BB.
113 VRegPHIUse VRegPHIUseCount;
114
115 // Defs of PHI sources which are implicit_def.
117
118 // Map reusable lowered PHI node -> incoming join register.
119 using LoweredPHIMap =
121 LoweredPHIMap LoweredPHIs;
122
123 MachineFunctionPass *P = nullptr;
124 MachineFunctionAnalysisManager *MFAM = nullptr;
125
126public:
127 PHIEliminationImpl(MachineFunctionPass *P) : P(P) {
128 auto *LVWrapper = P->getAnalysisIfAvailable<LiveVariablesWrapperPass>();
129 auto *LISWrapper = P->getAnalysisIfAvailable<LiveIntervalsWrapperPass>();
130 auto *MLIWrapper = P->getAnalysisIfAvailable<MachineLoopInfoWrapperPass>();
131 auto *MDTWrapper =
132 P->getAnalysisIfAvailable<MachineDominatorTreeWrapperPass>();
133 auto *PDTWrapper =
134 P->getAnalysisIfAvailable<MachinePostDominatorTreeWrapperPass>();
135 auto *MBPIWrapper =
136 P->getAnalysisIfAvailable<MachineBranchProbabilityInfoWrapperPass>();
137 auto *MBFIWrapper =
138 P->getAnalysisIfAvailable<MachineBlockFrequencyInfoWrapperPass>();
139
140 LV = LVWrapper ? &LVWrapper->getLV() : nullptr;
141 LIS = LISWrapper ? &LISWrapper->getLIS() : nullptr;
142 MLI = MLIWrapper ? &MLIWrapper->getLI() : nullptr;
143 MDT = MDTWrapper ? &MDTWrapper->getDomTree() : nullptr;
144 PDT = PDTWrapper ? &PDTWrapper->getPostDomTree() : nullptr;
145 MBPI = MBPIWrapper ? &MBPIWrapper->getMBPI() : nullptr;
146 MBFI = MBFIWrapper ? &MBFIWrapper->getMBFI() : nullptr;
147 }
148
149 PHIEliminationImpl(MachineFunction &MF, MachineFunctionAnalysisManager &AM)
150 : LV(AM.getCachedResult<LiveVariablesAnalysis>(MF)),
151 LIS(AM.getCachedResult<LiveIntervalsAnalysis>(MF)),
152 MLI(AM.getCachedResult<MachineLoopAnalysis>(MF)),
153 MDT(AM.getCachedResult<MachineDominatorTreeAnalysis>(MF)),
154 PDT(AM.getCachedResult<MachinePostDominatorTreeAnalysis>(MF)),
155 MBPI(AM.getCachedResult<MachineBranchProbabilityAnalysis>(MF)),
156 MBFI(AM.getCachedResult<MachineBlockFrequencyAnalysis>(MF)), MFAM(&AM) {
157 }
158
159 bool run(MachineFunction &MF);
160};
161
162class PHIElimination : public MachineFunctionPass {
163public:
164 static char ID; // Pass identification, replacement for typeid
165
166 PHIElimination() : MachineFunctionPass(ID) {}
167
168 bool runOnMachineFunction(MachineFunction &MF) override {
169 PHIEliminationImpl Impl(this);
170 return Impl.run(MF);
171 }
172
173 MachineFunctionProperties getSetProperties() const override {
174 return MachineFunctionProperties().setNoPHIs();
175 }
176
177 void getAnalysisUsage(AnalysisUsage &AU) const override;
178};
179
180} // end anonymous namespace
181
185 PHIEliminationImpl Impl(MF, MFAM);
186 bool Changed = Impl.run(MF);
187 if (!Changed)
188 return PreservedAnalyses::all();
190 PA.preserve<LiveIntervalsAnalysis>();
191 PA.preserve<LiveVariablesAnalysis>();
192 PA.preserve<SlotIndexesAnalysis>();
193 PA.preserve<MachineDominatorTreeAnalysis>();
195 PA.preserve<MachineLoopAnalysis>();
196 PA.preserve<MachineBlockFrequencyAnalysis>();
197 return PA;
198}
199
200STATISTIC(NumLowered, "Number of phis lowered");
201STATISTIC(NumCriticalEdgesSplit, "Number of critical edges split");
202STATISTIC(NumReused, "Number of reused lowered phis");
203
204char PHIElimination::ID = 0;
205
206char &llvm::PHIEliminationID = PHIElimination::ID;
207
209 "Eliminate PHI nodes for register allocation", false,
210 false)
215 "Eliminate PHI nodes for register allocation", false, false)
216
217void PHIElimination::getAnalysisUsage(AnalysisUsage &AU) const {
218 AU.addUsedIfAvailable<LiveVariablesWrapperPass>();
219 AU.addUsedIfAvailable<MachineLoopInfoWrapperPass>();
220 AU.addPreserved<LiveVariablesWrapperPass>();
221 AU.addPreserved<SlotIndexesWrapperPass>();
222 AU.addPreserved<LiveIntervalsWrapperPass>();
223 AU.addPreserved<MachineDominatorTreeWrapperPass>();
224 AU.addPreserved<MachinePostDominatorTreeWrapperPass>();
225 AU.addPreserved<MachineLoopInfoWrapperPass>();
226 AU.addPreserved<MachineBlockFrequencyInfoWrapperPass>();
228}
229
230bool PHIEliminationImpl::run(MachineFunction &MF) {
231 MRI = &MF.getRegInfo();
232
233 MachineDomTreeUpdater MDTU(MDT, PDT,
234 MachineDomTreeUpdater::UpdateStrategy::Lazy);
235
236 bool Changed = false;
237
238 // Split critical edges to help the coalescer.
239 if (!DisableEdgeSplitting && (LV || LIS)) {
240 // A set of live-in regs for each MBB which is used to update LV
241 // efficiently also with large functions.
242 std::vector<SparseBitVector<>> LiveInSets;
243 if (LV) {
244 LiveInSets.resize(MF.size());
245 for (unsigned Index = 0, e = MRI->getNumVirtRegs(); Index != e; ++Index) {
246 // Set the bit for this register for each MBB where it is
247 // live-through or live-in (killed).
248 Register VirtReg = Register::index2VirtReg(Index);
249 MachineInstr *DefMI = MRI->getVRegDef(VirtReg);
250 if (!DefMI)
251 continue;
252 LiveVariables::VarInfo &VI = LV->getVarInfo(VirtReg);
253 SparseBitVector<>::iterator AliveBlockItr = VI.AliveBlocks.begin();
254 SparseBitVector<>::iterator EndItr = VI.AliveBlocks.end();
255 while (AliveBlockItr != EndItr) {
256 unsigned BlockNum = *(AliveBlockItr++);
257 LiveInSets[BlockNum].set(Index);
258 }
259 // The register is live into an MBB in which it is killed but not
260 // defined. See comment for VarInfo in LiveVariables.h.
261 MachineBasicBlock *DefMBB = DefMI->getParent();
262 if (VI.Kills.size() > 1 ||
263 (!VI.Kills.empty() && VI.Kills.front()->getParent() != DefMBB))
264 for (auto *MI : VI.Kills)
265 LiveInSets[MI->getParent()->getNumber()].set(Index);
266 }
267 }
268
269 for (auto &MBB : MF)
270 Changed |=
271 SplitPHIEdges(MF, MBB, MLI, (LV ? &LiveInSets : nullptr), MDTU);
272 }
273
274 // This pass takes the function out of SSA form.
275 MRI->leaveSSA();
276
277 // Populate VRegPHIUseCount
278 if (LV || LIS)
279 analyzePHINodes(MF);
280
281 // Eliminate PHI instructions by inserting copies into predecessor blocks.
282 for (auto &MBB : MF)
283 Changed |= EliminatePHINodes(MF, MBB);
284
285 // Remove dead IMPLICIT_DEF instructions.
286 for (MachineInstr *DefMI : ImpDefs) {
287 Register DefReg = DefMI->getOperand(0).getReg();
288 if (MRI->use_nodbg_empty(DefReg)) {
289 if (LIS)
292 }
293 }
294
295 // Clean up the lowered PHI instructions.
296 for (auto &I : LoweredPHIs) {
297 if (LIS)
298 LIS->RemoveMachineInstrFromMaps(*I.first);
299 MF.deleteMachineInstr(I.first);
300 }
301
302 LoweredPHIs.clear();
303 ImpDefs.clear();
304 VRegPHIUseCount.clear();
305
306 MF.getProperties().setNoPHIs();
307
308 return Changed;
309}
310
311/// EliminatePHINodes - Eliminate phi nodes by inserting copy instructions in
312/// predecessor basic blocks.
313bool PHIEliminationImpl::EliminatePHINodes(MachineFunction &MF,
315 if (MBB.empty() || !MBB.front().isPHI())
316 return false; // Quick exit for basic blocks without PHIs.
317
318 // Get an iterator to the last PHI node.
320 std::prev(MBB.SkipPHIsAndLabels(MBB.begin()));
321
322 // If all incoming edges are critical, we try to deduplicate identical PHIs so
323 // that we generate fewer copies. If at any edge is non-critical, we either
324 // have less than two predecessors (=> no PHIs) or a predecessor has only us
325 // as a successor (=> identical PHI node can't occur in different block).
326 bool AllEdgesCritical = MBB.pred_size() >= 2;
327 for (MachineBasicBlock *Pred : MBB.predecessors()) {
328 if (Pred->succ_size() < 2) {
329 AllEdgesCritical = false;
330 break;
331 }
332 }
333
334 while (MBB.front().isPHI())
335 LowerPHINode(MBB, LastPHIIt, AllEdgesCritical);
336
337 return true;
338}
339
340/// Return true if all defs of VirtReg are implicit-defs.
341/// This includes registers with no defs.
342static bool isImplicitlyDefined(Register VirtReg,
343 const MachineRegisterInfo &MRI) {
344 for (MachineInstr &DI : MRI.def_instructions(VirtReg))
345 if (!DI.isImplicitDef())
346 return false;
347 return true;
348}
349
350/// Return true if all sources of the phi node are implicit_def's, or undef's.
351static bool allPhiOperandsUndefined(const MachineInstr &MPhi,
352 const MachineRegisterInfo &MRI) {
353 for (unsigned I = 1, E = MPhi.getNumOperands(); I != E; I += 2) {
354 const MachineOperand &MO = MPhi.getOperand(I);
355 if (!isImplicitlyDefined(MO.getReg(), MRI) && !MO.isUndef())
356 return false;
357 }
358 return true;
359}
360/// LowerPHINode - Lower the PHI node at the top of the specified block.
361void PHIEliminationImpl::LowerPHINode(MachineBasicBlock &MBB,
363 bool AllEdgesCritical) {
364 ++NumLowered;
365
366 MachineBasicBlock::iterator AfterPHIsIt = std::next(LastPHIIt);
367
368 // Unlink the PHI node from the basic block, but don't delete the PHI yet.
369 MachineInstr *MPhi = MBB.remove(&*MBB.begin());
370
371 unsigned NumSrcs = (MPhi->getNumOperands() - 1) / 2;
372 Register DestReg = MPhi->getOperand(0).getReg();
373 assert(MPhi->getOperand(0).getSubReg() == 0 && "Can't handle sub-reg PHIs");
374 bool isDead = MPhi->getOperand(0).isDead();
375
376 // Create a new register for the incoming PHI arguments.
378 Register IncomingReg;
379 bool EliminateNow = true; // delay elimination of nodes in LoweredPHIs
380 bool reusedIncoming = false; // Is IncomingReg reused from an earlier PHI?
381
382 // Insert a register to register copy at the top of the current block (but
383 // after any remaining phi nodes) which copies the new incoming register
384 // into the phi node destination.
385 MachineInstr *PHICopy = nullptr;
387 if (allPhiOperandsUndefined(*MPhi, *MRI))
388 // If all sources of a PHI node are implicit_def or undef uses, just emit an
389 // implicit_def instead of a copy.
390 PHICopy = BuildMI(MBB, AfterPHIsIt, MPhi->getDebugLoc(),
391 TII->get(TargetOpcode::IMPLICIT_DEF), DestReg);
392 else {
393 // Can we reuse an earlier PHI node? This only happens for critical edges,
394 // typically those created by tail duplication. Typically, an identical PHI
395 // node can't occur, so avoid hashing/storing such PHIs, which is somewhat
396 // expensive.
397 Register *Entry = nullptr;
398 if (AllEdgesCritical)
399 Entry = &LoweredPHIs[MPhi];
400 if (Entry && *Entry) {
401 // An identical PHI node was already lowered. Reuse the incoming register.
402 IncomingReg = *Entry;
403 reusedIncoming = true;
404 ++NumReused;
405 LLVM_DEBUG(dbgs() << "Reusing " << printReg(IncomingReg) << " for "
406 << *MPhi);
407 } else {
408 const TargetRegisterClass *RC = MF.getRegInfo().getRegClass(DestReg);
409 IncomingReg = MF.getRegInfo().createVirtualRegister(RC);
410 if (Entry) {
411 EliminateNow = false;
412 *Entry = IncomingReg;
413 }
414 }
415
416 // Give the target possiblity to handle special cases fallthrough otherwise
417 PHICopy = TII->createPHIDestinationCopy(
418 MBB, AfterPHIsIt, MPhi->getDebugLoc(), IncomingReg, DestReg);
419 }
420
421 if (MPhi->peekDebugInstrNum()) {
422 // If referred to by debug-info, store where this PHI was.
424 unsigned ID = MPhi->peekDebugInstrNum();
425 auto P = MachineFunction::DebugPHIRegallocPos(&MBB, IncomingReg, 0);
426 auto Res = MF->DebugPHIPositions.insert({ID, P});
427 assert(Res.second);
428 (void)Res;
429 }
430
431 // Update live variable information if there is any.
432 if (LV) {
433 if (IncomingReg) {
434 LiveVariables::VarInfo &VI = LV->getVarInfo(IncomingReg);
435
436 MachineInstr *OldKill = nullptr;
437 bool IsPHICopyAfterOldKill = false;
438
439 if (reusedIncoming && (OldKill = VI.findKill(&MBB))) {
440 // Calculate whether the PHICopy is after the OldKill.
441 // In general, the PHICopy is inserted as the first non-phi instruction
442 // by default, so it's before the OldKill. But some Target hooks for
443 // createPHIDestinationCopy() may modify the default insert position of
444 // PHICopy.
445 for (auto I = MBB.SkipPHIsAndLabels(MBB.begin()), E = MBB.end(); I != E;
446 ++I) {
447 if (I == PHICopy)
448 break;
449
450 if (I == OldKill) {
451 IsPHICopyAfterOldKill = true;
452 break;
453 }
454 }
455 }
456
457 // When we are reusing the incoming register and it has been marked killed
458 // by OldKill, if the PHICopy is after the OldKill, we should remove the
459 // killed flag from OldKill.
460 if (IsPHICopyAfterOldKill) {
461 LLVM_DEBUG(dbgs() << "Remove old kill from " << *OldKill);
462 LV->removeVirtualRegisterKilled(IncomingReg, *OldKill);
464 }
465
466 // Add information to LiveVariables to know that the first used incoming
467 // value or the resued incoming value whose PHICopy is after the OldKIll
468 // is killed. Note that because the value is defined in several places
469 // (once each for each incoming block), the "def" block and instruction
470 // fields for the VarInfo is not filled in.
471 if (!OldKill || IsPHICopyAfterOldKill)
472 LV->addVirtualRegisterKilled(IncomingReg, *PHICopy);
473 }
474
475 // Since we are going to be deleting the PHI node, if it is the last use of
476 // any registers, or if the value itself is dead, we need to move this
477 // information over to the new copy we just inserted.
479
480 // If the result is dead, update LV.
481 if (isDead) {
482 LV->addVirtualRegisterDead(DestReg, *PHICopy);
483 LV->removeVirtualRegisterDead(DestReg, *MPhi);
484 }
485 }
486
487 // Update LiveIntervals for the new copy or implicit def.
488 if (LIS) {
489 SlotIndex DestCopyIndex = LIS->InsertMachineInstrInMaps(*PHICopy);
490
491 SlotIndex MBBStartIndex = LIS->getMBBStartIdx(&MBB);
492 if (IncomingReg) {
493 // Add the region from the beginning of MBB to the copy instruction to
494 // IncomingReg's live interval.
495 LiveInterval &IncomingLI = LIS->getOrCreateEmptyInterval(IncomingReg);
496 VNInfo *IncomingVNI = IncomingLI.getVNInfoAt(MBBStartIndex);
497 if (!IncomingVNI)
498 IncomingVNI =
499 IncomingLI.getNextValue(MBBStartIndex, LIS->getVNInfoAllocator());
501 MBBStartIndex, DestCopyIndex.getRegSlot(), IncomingVNI));
502 }
503
504 LiveInterval &DestLI = LIS->getInterval(DestReg);
505 assert(!DestLI.empty() && "PHIs should have non-empty LiveIntervals.");
506
507 SlotIndex NewStart = DestCopyIndex.getRegSlot();
508
509 SmallVector<LiveRange *> ToUpdate({&DestLI});
510 for (auto &SR : DestLI.subranges())
511 ToUpdate.push_back(&SR);
512
513 for (auto LR : ToUpdate) {
514 auto DestSegment = LR->find(MBBStartIndex);
515 assert(DestSegment != LR->end() &&
516 "PHI destination must be live in block");
517
518 if (LR->endIndex().isDead()) {
519 // A dead PHI's live range begins and ends at the start of the MBB, but
520 // the lowered copy, which will still be dead, needs to begin and end at
521 // the copy instruction.
522 VNInfo *OrigDestVNI = LR->getVNInfoAt(DestSegment->start);
523 assert(OrigDestVNI && "PHI destination should be live at block entry.");
524 LR->removeSegment(DestSegment->start, DestSegment->start.getDeadSlot());
525 LR->createDeadDef(NewStart, LIS->getVNInfoAllocator());
526 LR->removeValNo(OrigDestVNI);
527 continue;
528 }
529
530 // Destination copies are not inserted in the same order as the PHI nodes
531 // they replace. Hence the start of the live range may need to be adjusted
532 // to match the actual slot index of the copy.
533 if (DestSegment->start > NewStart) {
534 VNInfo *VNI = LR->getVNInfoAt(DestSegment->start);
535 assert(VNI && "value should be defined for known segment");
536 LR->addSegment(
537 LiveInterval::Segment(NewStart, DestSegment->start, VNI));
538 } else if (DestSegment->start < NewStart) {
539 assert(DestSegment->start >= MBBStartIndex);
540 assert(DestSegment->end >= DestCopyIndex.getRegSlot());
541 LR->removeSegment(DestSegment->start, NewStart);
542 }
543 VNInfo *DestVNI = LR->getVNInfoAt(NewStart);
544 assert(DestVNI && "PHI destination should be live at its definition.");
545 DestVNI->def = NewStart;
546 }
547 }
548
549 // Adjust the VRegPHIUseCount map to account for the removal of this PHI node.
550 if (LV || LIS) {
551 for (unsigned i = 1; i != MPhi->getNumOperands(); i += 2) {
552 if (!MPhi->getOperand(i).isUndef()) {
553 --VRegPHIUseCount[BBVRegPair(
554 MPhi->getOperand(i + 1).getMBB()->getNumber(),
555 MPhi->getOperand(i).getReg())];
556 }
557 }
558 }
559
560 // Now loop over all of the incoming arguments, changing them to copy into the
561 // IncomingReg register in the corresponding predecessor basic block.
563 for (int i = NumSrcs - 1; i >= 0; --i) {
564 Register SrcReg = MPhi->getOperand(i * 2 + 1).getReg();
565 unsigned SrcSubReg = MPhi->getOperand(i * 2 + 1).getSubReg();
566 bool SrcUndef = MPhi->getOperand(i * 2 + 1).isUndef() ||
567 isImplicitlyDefined(SrcReg, *MRI);
568 assert(SrcReg.isVirtual() &&
569 "Machine PHI Operands must all be virtual registers!");
570
571 // Get the MachineBasicBlock equivalent of the BasicBlock that is the source
572 // path the PHI.
573 MachineBasicBlock &opBlock = *MPhi->getOperand(i * 2 + 2).getMBB();
574
575 // Check to make sure we haven't already emitted the copy for this block.
576 // This can happen because PHI nodes may have multiple entries for the same
577 // basic block.
578 if (!MBBsInsertedInto.insert(&opBlock).second)
579 continue; // If the copy has already been emitted, we're done.
580
581 MachineInstr *SrcRegDef = MRI->getVRegDef(SrcReg);
582 if (SrcRegDef && TII->isUnspillableTerminator(SrcRegDef)) {
583 assert(SrcRegDef->getOperand(0).isReg() &&
584 SrcRegDef->getOperand(0).isDef() &&
585 "Expected operand 0 to be a reg def!");
586 // Now that the PHI's use has been removed (as the instruction was
587 // removed) there should be no other uses of the SrcReg.
588 assert(MRI->use_empty(SrcReg) &&
589 "Expected a single use from UnspillableTerminator");
590 SrcRegDef->getOperand(0).setReg(IncomingReg);
591
592 // Update LiveVariables.
593 if (LV) {
594 LiveVariables::VarInfo &SrcVI = LV->getVarInfo(SrcReg);
595 LiveVariables::VarInfo &IncomingVI = LV->getVarInfo(IncomingReg);
596 IncomingVI.AliveBlocks = std::move(SrcVI.AliveBlocks);
597 SrcVI.AliveBlocks.clear();
598 }
599
600 continue;
601 }
602
603 // Find a safe location to insert the copy, this may be the first terminator
604 // in the block (or end()).
606 findPHICopyInsertPoint(&opBlock, &MBB, SrcReg);
607
608 // Insert the copy.
609 MachineInstr *NewSrcInstr = nullptr;
610 if (!reusedIncoming && IncomingReg) {
611 if (SrcUndef) {
612 // The source register is undefined, so there is no need for a real
613 // COPY, but we still need to ensure joint dominance by defs.
614 // Insert an IMPLICIT_DEF instruction.
615 NewSrcInstr =
616 BuildMI(opBlock, InsertPos, MPhi->getDebugLoc(),
617 TII->get(TargetOpcode::IMPLICIT_DEF), IncomingReg);
618
619 // Clean up the old implicit-def, if there even was one.
620 if (MachineInstr *DefMI = MRI->getVRegDef(SrcReg))
621 if (DefMI->isImplicitDef())
622 ImpDefs.insert(DefMI);
623 } else {
624 // Delete the debug location, since the copy is inserted into a
625 // different basic block.
626 NewSrcInstr = TII->createPHISourceCopy(opBlock, InsertPos, nullptr,
627 SrcReg, SrcSubReg, IncomingReg);
628 }
629 }
630
631 // We only need to update the LiveVariables kill of SrcReg if this was the
632 // last PHI use of SrcReg to be lowered on this CFG edge and it is not live
633 // out of the predecessor. We can also ignore undef sources.
634 if (LV && !SrcUndef &&
635 !VRegPHIUseCount[BBVRegPair(opBlock.getNumber(), SrcReg)] &&
636 !LV->isLiveOut(SrcReg, opBlock)) {
637 // We want to be able to insert a kill of the register if this PHI (aka,
638 // the copy we just inserted) is the last use of the source value. Live
639 // variable analysis conservatively handles this by saying that the value
640 // is live until the end of the block the PHI entry lives in. If the value
641 // really is dead at the PHI copy, there will be no successor blocks which
642 // have the value live-in.
643
644 // Okay, if we now know that the value is not live out of the block, we
645 // can add a kill marker in this block saying that it kills the incoming
646 // value!
647
648 // In our final twist, we have to decide which instruction kills the
649 // register. In most cases this is the copy, however, terminator
650 // instructions at the end of the block may also use the value. In this
651 // case, we should mark the last such terminator as being the killing
652 // block, not the copy.
653 MachineBasicBlock::iterator KillInst = opBlock.end();
654 for (MachineBasicBlock::iterator Term = InsertPos; Term != opBlock.end();
655 ++Term) {
656 if (Term->readsRegister(SrcReg, /*TRI=*/nullptr))
657 KillInst = Term;
658 }
659
660 if (KillInst == opBlock.end()) {
661 // No terminator uses the register.
662
663 if (reusedIncoming || !IncomingReg) {
664 // We may have to rewind a bit if we didn't insert a copy this time.
665 KillInst = InsertPos;
666 while (KillInst != opBlock.begin()) {
667 --KillInst;
668 if (KillInst->isDebugInstr())
669 continue;
670 if (KillInst->readsRegister(SrcReg, /*TRI=*/nullptr))
671 break;
672 }
673 } else {
674 // We just inserted this copy.
675 KillInst = NewSrcInstr;
676 }
677 }
678 assert(KillInst->readsRegister(SrcReg, /*TRI=*/nullptr) &&
679 "Cannot find kill instruction");
680
681 // Finally, mark it killed.
682 LV->addVirtualRegisterKilled(SrcReg, *KillInst);
683
684 // This vreg no longer lives all of the way through opBlock.
685 unsigned opBlockNum = opBlock.getNumber();
686 LV->getVarInfo(SrcReg).AliveBlocks.reset(opBlockNum);
687 }
688
689 if (LIS) {
690 if (NewSrcInstr) {
691 LIS->InsertMachineInstrInMaps(*NewSrcInstr);
692 LIS->addSegmentToEndOfBlock(IncomingReg, *NewSrcInstr);
693 }
694
695 if (!SrcUndef &&
696 !VRegPHIUseCount[BBVRegPair(opBlock.getNumber(), SrcReg)]) {
697 LiveInterval &SrcLI = LIS->getInterval(SrcReg);
698
699 bool isLiveOut = false;
700 for (MachineBasicBlock *Succ : opBlock.successors()) {
701 SlotIndex startIdx = LIS->getMBBStartIdx(Succ);
702 VNInfo *VNI = SrcLI.getVNInfoAt(startIdx);
703
704 // Definitions by other PHIs are not truly live-in for our purposes.
705 if (VNI && VNI->def != startIdx) {
706 isLiveOut = true;
707 break;
708 }
709 }
710
711 if (!isLiveOut) {
712 MachineBasicBlock::iterator KillInst = opBlock.end();
713 for (MachineBasicBlock::iterator Term = InsertPos;
714 Term != opBlock.end(); ++Term) {
715 if (Term->readsRegister(SrcReg, /*TRI=*/nullptr))
716 KillInst = Term;
717 }
718
719 if (KillInst == opBlock.end()) {
720 // No terminator uses the register.
721
722 if (reusedIncoming || !IncomingReg) {
723 // We may have to rewind a bit if we didn't just insert a copy.
724 KillInst = InsertPos;
725 while (KillInst != opBlock.begin()) {
726 --KillInst;
727 if (KillInst->isDebugInstr())
728 continue;
729 if (KillInst->readsRegister(SrcReg, /*TRI=*/nullptr))
730 break;
731 }
732 } else {
733 // We just inserted this copy.
734 KillInst = std::prev(InsertPos);
735 }
736 }
737 assert(KillInst->readsRegister(SrcReg, /*TRI=*/nullptr) &&
738 "Cannot find kill instruction");
739
740 SlotIndex LastUseIndex = LIS->getInstructionIndex(*KillInst);
741 SrcLI.removeSegment(LastUseIndex.getRegSlot(),
742 LIS->getMBBEndIdx(&opBlock));
743 for (auto &SR : SrcLI.subranges()) {
744 SR.removeSegment(LastUseIndex.getRegSlot(),
745 LIS->getMBBEndIdx(&opBlock));
746 }
747 }
748 }
749 }
750 }
751
752 // Really delete the PHI instruction now, if it is not in the LoweredPHIs map.
753 if (EliminateNow) {
754 if (LIS)
755 LIS->RemoveMachineInstrFromMaps(*MPhi);
756 MF.deleteMachineInstr(MPhi);
757 }
758}
759
760/// analyzePHINodes - Gather information about the PHI nodes in here. In
761/// particular, we want to map the number of uses of a virtual register which is
762/// used in a PHI node. We map that to the BB the vreg is coming from. This is
763/// used later to determine when the vreg is killed in the BB.
764void PHIEliminationImpl::analyzePHINodes(const MachineFunction &MF) {
765 for (const auto &MBB : MF) {
766 for (const auto &BBI : MBB) {
767 if (!BBI.isPHI())
768 break;
769 for (unsigned i = 1, e = BBI.getNumOperands(); i != e; i += 2) {
770 if (!BBI.getOperand(i).isUndef()) {
771 ++VRegPHIUseCount[BBVRegPair(
772 BBI.getOperand(i + 1).getMBB()->getNumber(),
773 BBI.getOperand(i).getReg())];
774 }
775 }
776 }
777 }
778}
779
780bool PHIEliminationImpl::SplitPHIEdges(
782 std::vector<SparseBitVector<>> *LiveInSets, MachineDomTreeUpdater &MDTU) {
783 if (MBB.empty() || !MBB.front().isPHI() || MBB.isEHPad())
784 return false; // Quick exit for basic blocks without PHIs.
785
786 const MachineLoop *CurLoop = MLI ? MLI->getLoopFor(&MBB) : nullptr;
787 bool IsLoopHeader = CurLoop && &MBB == CurLoop->getHeader();
788
789 bool Changed = false;
790 for (MachineBasicBlock::iterator BBI = MBB.begin(), BBE = MBB.end();
791 BBI != BBE && BBI->isPHI(); ++BBI) {
792 for (unsigned i = 1, e = BBI->getNumOperands(); i != e; i += 2) {
793 Register Reg = BBI->getOperand(i).getReg();
794 MachineBasicBlock *PreMBB = BBI->getOperand(i + 1).getMBB();
795 // Is there a critical edge from PreMBB to MBB?
796 if (PreMBB->succ_size() == 1)
797 continue;
798
799 // Avoid splitting backedges of loops. It would introduce small
800 // out-of-line blocks into the loop which is very bad for code placement.
801 if (PreMBB == &MBB && !SplitAllCriticalEdges)
802 continue;
803 const MachineLoop *PreLoop = MLI ? MLI->getLoopFor(PreMBB) : nullptr;
804 if (IsLoopHeader && PreLoop == CurLoop && !SplitAllCriticalEdges)
805 continue;
806
807 // LV doesn't consider a phi use live-out, so isLiveOut only returns true
808 // when the source register is live-out for some other reason than a phi
809 // use. That means the copy we will insert in PreMBB won't be a kill, and
810 // there is a risk it may not be coalesced away.
811 //
812 // If the copy would be a kill, there is no need to split the edge.
813 bool ShouldSplit = isLiveOutPastPHIs(Reg, PreMBB);
814 if (!ShouldSplit && !NoPhiElimLiveOutEarlyExit)
815 continue;
816 if (ShouldSplit) {
817 LLVM_DEBUG(dbgs() << printReg(Reg) << " live-out before critical edge "
818 << printMBBReference(*PreMBB) << " -> "
819 << printMBBReference(MBB) << ": " << *BBI);
820 }
821
822 // If Reg is not live-in to MBB, it means it must be live-in to some
823 // other PreMBB successor, and we can avoid the interference by splitting
824 // the edge.
825 //
826 // If Reg *is* live-in to MBB, the interference is inevitable and a copy
827 // is likely to be left after coalescing. If we are looking at a loop
828 // exiting edge, split it so we won't insert code in the loop, otherwise
829 // don't bother.
830 ShouldSplit = ShouldSplit && !isLiveIn(Reg, &MBB);
831
832 // Check for a loop exiting edge.
833 if (!ShouldSplit && CurLoop != PreLoop) {
834 LLVM_DEBUG({
835 dbgs() << "Split wouldn't help, maybe avoid loop copies?\n";
836 if (PreLoop)
837 dbgs() << "PreLoop: " << *PreLoop;
838 if (CurLoop)
839 dbgs() << "CurLoop: " << *CurLoop;
840 });
841 // This edge could be entering a loop, exiting a loop, or it could be
842 // both: Jumping directly form one loop to the header of a sibling
843 // loop.
844 // Split unless this edge is entering CurLoop from an outer loop.
845 ShouldSplit = PreLoop && !PreLoop->contains(CurLoop);
846 }
847 if (!ShouldSplit && !SplitAllCriticalEdges)
848 continue;
849 MachineBasicBlock *NewBB;
850 if (P)
851 NewBB = PreMBB->SplitCriticalEdge(&MBB, *P, LiveInSets, &MDTU);
852 else
853 NewBB = PreMBB->SplitCriticalEdge(&MBB, *MFAM, LiveInSets, &MDTU);
854 if (!NewBB) {
855 LLVM_DEBUG(dbgs() << "Failed to split critical edge.\n");
856 continue;
857 }
858
859 // Patch up MBFI after split if it is available.
860 if (MBFI) {
861 assert(MBPI);
862 MBFI->onEdgeSplit(*PreMBB, *NewBB, *MBPI);
863 }
864
865 Changed = true;
866 ++NumCriticalEdgesSplit;
867 }
868 }
869 return Changed;
870}
871
872bool PHIEliminationImpl::isLiveIn(Register Reg, const MachineBasicBlock *MBB) {
873 assert((LV || LIS) &&
874 "isLiveIn() requires either LiveVariables or LiveIntervals");
875 if (LIS)
876 return LIS->isLiveInToMBB(LIS->getInterval(Reg), MBB);
877 else
878 return LV->isLiveIn(Reg, *MBB);
879}
880
881bool PHIEliminationImpl::isLiveOutPastPHIs(Register Reg,
882 const MachineBasicBlock *MBB) {
883 assert((LV || LIS) &&
884 "isLiveOutPastPHIs() requires either LiveVariables or LiveIntervals");
885 // LiveVariables considers uses in PHIs to be in the predecessor basic block,
886 // so that a register used only in a PHI is not live out of the block. In
887 // contrast, LiveIntervals considers uses in PHIs to be on the edge rather
888 // than in the predecessor basic block, so that a register used only in a PHI
889 // is live out of the block.
890 if (LIS) {
891 const LiveInterval &LI = LIS->getInterval(Reg);
892 for (const MachineBasicBlock *SI : MBB->successors())
893 if (LI.liveAt(LIS->getMBBStartIdx(SI)))
894 return true;
895 return false;
896 } else {
897 return LV->isLiveOut(Reg, *MBB);
898 }
899}
unsigned const MachineRegisterInfo * MRI
MachineInstrBuilder MachineInstrBuilder & DefMI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock & MBB
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines the DenseMap class.
#define DEBUG_TYPE
const HexagonInstrInfo * TII
IRTranslator LLVM IR MI
#define I(x, y, z)
Definition MD5.cpp:57
Register Reg
#define P(N)
static bool allPhiOperandsUndefined(const MachineInstr &MPhi, const MachineRegisterInfo &MRI)
Return true if all sources of the phi node are implicit_def's, or undef's.
static cl::opt< bool > NoPhiElimLiveOutEarlyExit("no-phi-elim-live-out-early-exit", cl::init(false), cl::Hidden, cl::desc("Do not use an early exit if isLiveOutPastPHIs returns true."))
static bool isImplicitlyDefined(Register VirtReg, const MachineRegisterInfo &MRI)
Return true if all defs of VirtReg are implicit-defs.
static cl::opt< bool > DisableEdgeSplitting("disable-phi-elim-edge-splitting", cl::init(false), cl::Hidden, cl::desc("Disable critical edge splitting " "during PHI elimination"))
static cl::opt< bool > SplitAllCriticalEdges("phi-elim-split-all-critical-edges", cl::init(false), cl::Hidden, cl::desc("Split all critical edges during " "PHI elimination"))
#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
static bool isLiveOut(const MachineBasicBlock &MBB, unsigned Reg)
bool isDead(const MachineInstr &MI, const MachineRegisterInfo &MRI)
This file defines the SmallPtrSet class.
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
Represent the analysis usage information of a pass.
LiveInterval - This class represents the liveness of a register, or stack slot.
iterator_range< subrange_iterator > subranges()
SlotIndex getMBBStartIdx(const MachineBasicBlock *mbb) const
Return the first index in the given basic block.
SlotIndex InsertMachineInstrInMaps(MachineInstr &MI)
LiveInterval & getOrCreateEmptyInterval(Register Reg)
Return an existing interval for Reg.
SlotIndex getInstructionIndex(const MachineInstr &Instr) const
Returns the base index of the given instruction.
void RemoveMachineInstrFromMaps(MachineInstr &MI)
VNInfo::Allocator & getVNInfoAllocator()
SlotIndex getMBBEndIdx(const MachineBasicBlock *mbb) const
Return the last index in the given basic block.
LiveInterval & getInterval(Register Reg)
LLVM_ABI LiveInterval::Segment addSegmentToEndOfBlock(Register Reg, MachineInstr &startInst)
Given a register and an instruction, adds a live segment from that instruction to the end of its MBB.
bool isLiveInToMBB(const LiveRange &LR, const MachineBasicBlock *mbb) const
LLVM_ABI iterator addSegment(Segment S)
Add the specified Segment to this range, merging segments as appropriate.
bool liveAt(SlotIndex index) const
bool empty() const
VNInfo * getNextValue(SlotIndex Def, VNInfo::Allocator &VNInfoAllocator)
getNextValue - Create a new value number and return it.
LLVM_ABI void removeSegment(SlotIndex Start, SlotIndex End, bool RemoveDeadValNo=false)
Remove the specified interval from this live range.
VNInfo * getVNInfoAt(SlotIndex Idx) const
getVNInfoAt - Return the VNInfo that is live at Idx, or NULL.
bool removeVirtualRegisterDead(Register Reg, MachineInstr &MI)
removeVirtualRegisterDead - Remove the specified kill of the virtual register from the live variable ...
bool removeVirtualRegisterKilled(Register Reg, MachineInstr &MI)
removeVirtualRegisterKilled - Remove the specified kill of the virtual register from the live variabl...
LLVM_ABI void removeVirtualRegistersKilled(MachineInstr &MI)
removeVirtualRegistersKilled - Remove all killed info for the specified instruction.
void addVirtualRegisterDead(Register IncomingReg, MachineInstr &MI, bool AddIfNotFound=false)
addVirtualRegisterDead - Add information about the fact that the specified register is dead after bei...
LLVM_ABI bool isLiveOut(Register Reg, const MachineBasicBlock &MBB)
isLiveOut - Determine if Reg is live out from MBB, when not considering PHI nodes.
bool isLiveIn(Register Reg, const MachineBasicBlock &MBB)
void addVirtualRegisterKilled(Register IncomingReg, MachineInstr &MI, bool AddIfNotFound=false)
addVirtualRegisterKilled - Add information about the fact that the specified register is killed after...
LLVM_ABI VarInfo & getVarInfo(Register Reg)
getVarInfo - Return the VarInfo structure for the specified VIRTUAL register.
bool contains(const LoopT *L) const
Return true if the specified loop is contained within in this loop.
BlockT * getHeader() const
LoopT * getLoopFor(const BlockT *BB) const
Return the inner most loop that BB lives in.
const MachineBlockFrequencyInfo & getMBFI() const
Definition MBFIWrapper.h:37
bool isEHPad() const
Returns true if the block is a landing pad.
MachineBasicBlock * SplitCriticalEdge(MachineBasicBlock *Succ, Pass &P, std::vector< SparseBitVector<> > *LiveInSets=nullptr, MachineDomTreeUpdater *MDTU=nullptr)
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
LLVM_ABI iterator SkipPHIsAndLabels(iterator I)
Return the first instruction in MBB after I that is not a PHI or a label.
MachineInstr * remove(MachineInstr *I)
Remove the unbundled instruction from the instruction list without deleting it.
LLVM_ABI void dump() const
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
iterator_range< succ_iterator > successors()
iterator_range< pred_iterator > predecessors()
MachineInstrBundleIterator< MachineInstr > iterator
MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate machine basic b...
LLVM_ABI void onEdgeSplit(const MachineBasicBlock &NewPredecessor, const MachineBasicBlock &NewSuccessor, const MachineBranchProbabilityInfo &MBPI)
incrementally calculate block frequencies when we split edges, to avoid full CFG traversal.
Analysis pass which computes a MachineDominatorTree.
Analysis pass which computes a MachineDominatorTree.
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...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Location of a PHI instruction that is also a debug-info variable value, for the duration of register ...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
unsigned size() const
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
DenseMap< unsigned, DebugPHIRegallocPos > DebugPHIPositions
Map of debug instruction numbers to the position of their PHI instructions during register allocation...
Representation of each machine instruction.
bool isImplicitDef() const
const MachineBasicBlock * getParent() const
unsigned getNumOperands() const
Retuns the total number of operands.
unsigned peekDebugInstrNum() const
Examine the instruction number of this MachineInstr.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
LLVM_ABI void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
const MachineOperand & getOperand(unsigned i) const
Analysis pass that exposes the MachineLoopInfo for a machine function.
MachineOperand class - Representation of each machine instruction operand.
unsigned getSubReg() const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
MachineBasicBlock * getMBB() const
LLVM_ABI void setReg(Register Reg)
Change the register this operand corresponds to.
Register getReg() const
getReg - Returns the register number.
MachinePostDominatorTree - an analysis pass wrapper for DominatorTree used to compute the post-domina...
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
LLVM_ABI Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
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
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
Definition Register.h:79
SlotIndex - An opaque wrapper around machine indexes.
Definition SlotIndexes.h:66
SlotIndex getRegSlot(bool EC=false) const
Returns the register use/def slot in the current instruction for a normal or early-clobber def.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
void reset(unsigned Idx)
SparseBitVectorIterator iterator
TargetInstrInfo - Interface to description of machine instruction set.
virtual const TargetInstrInfo * getInstrInfo() const
VNInfo - Value Number Information.
SlotIndex def
The index of the defining instruction.
Changed
@ Entry
Definition COFF.h:862
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
initializer< Ty > init(const Ty &Val)
PointerTypeMap run(const Module &M)
Compute the PointerTypeMap for the module M.
This is an optimization pass for GlobalISel generic memory operations.
Definition Types.h:26
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:207
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...
LLVM_ABI unsigned SplitAllCriticalEdges(Function &F, const CriticalEdgeSplittingOptions &Options=CriticalEdgeSplittingOptions())
Loop over all of the edges in the CFG, breaking critical edges as they are found.
LLVM_ABI char & PHIEliminationID
PHIElimination - This pass eliminates machine instruction PHI nodes by inserting copy instructions.
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.
LLVM_ABI Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
This represents a simple continuous liveness interval for a value.
VarInfo - This represents the regions where a virtual register is live in the program.
SparseBitVector AliveBlocks
AliveBlocks - Set of blocks in which this value is alive completely through.