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