@@ -136,7 +136,6 @@ INITIALIZE_PASS_END(PHIElimination, DEBUG_TYPE,
136
136
137
137
void PHIElimination::getAnalysisUsage(AnalysisUsage &AU) const {
138
138
AU.addUsedIfAvailable <LiveVariables>();
139
- AU.addUsedIfAvailable <LiveIntervals>();
140
139
AU.addPreserved <LiveVariables>();
141
140
AU.addPreserved <SlotIndexes>();
142
141
AU.addPreserved <LiveIntervals>();
@@ -393,7 +392,7 @@ void PHIElimination::LowerPHINode(MachineBasicBlock &MBB,
393
392
if (IncomingReg) {
394
393
// Add the region from the beginning of MBB to the copy instruction to
395
394
// IncomingReg's live interval.
396
- LiveInterval &IncomingLI = LIS->getOrCreateEmptyInterval (IncomingReg);
395
+ LiveInterval &IncomingLI = LIS->createEmptyInterval (IncomingReg);
397
396
VNInfo *IncomingVNI = IncomingLI.getVNInfoAt (MBBStartIndex);
398
397
if (!IncomingVNI)
399
398
IncomingVNI = IncomingLI.getNextValue (MBBStartIndex,
@@ -404,49 +403,24 @@ void PHIElimination::LowerPHINode(MachineBasicBlock &MBB,
404
403
}
405
404
406
405
LiveInterval &DestLI = LIS->getInterval (DestReg);
407
- assert (!DestLI.empty () && " PHIs should have non-empty LiveIntervals." );
408
-
409
- SlotIndex NewStart = DestCopyIndex.getRegSlot ();
410
-
411
- SmallVector<LiveRange*> ToUpdate;
412
- ToUpdate.push_back (&DestLI);
413
- for (auto &SR : DestLI.subranges ())
414
- ToUpdate.push_back (&SR);
415
-
416
- for (auto LR : ToUpdate) {
417
- auto DestSegment = LR->find (MBBStartIndex);
418
- assert (DestSegment != LR->end () && " PHI destination must be live in block" );
419
-
420
- if (LR->endIndex ().isDead ()) {
421
- // A dead PHI's live range begins and ends at the start of the MBB, but
422
- // the lowered copy, which will still be dead, needs to begin and end at
423
- // the copy instruction.
424
- VNInfo *OrigDestVNI = LR->getVNInfoAt (DestSegment->start );
425
- assert (OrigDestVNI && " PHI destination should be live at block entry." );
426
- LR->removeSegment (DestSegment->start , DestSegment->start .getDeadSlot ());
427
- LR->createDeadDef (NewStart, LIS->getVNInfoAllocator ());
428
- LR->removeValNo (OrigDestVNI);
429
- continue ;
430
- }
431
-
432
- if (DestSegment->start > NewStart) {
433
- // With a single PHI removed from block the index of the copy may be
434
- // lower than the original PHI. Extend live range backward to cover
435
- // the copy.
436
- VNInfo *VNI = LR->getVNInfoAt (DestSegment->start );
437
- assert (VNI && " value should be defined for known segment" );
438
- LR->addSegment (LiveInterval::Segment (
439
- NewStart, DestSegment->start , VNI));
440
- } else if (DestSegment->start < NewStart) {
441
- // Otherwise, remove the region from the beginning of MBB to the copy
442
- // instruction from DestReg's live interval.
443
- assert (DestSegment->start >= MBBStartIndex);
444
- assert (DestSegment->end >= DestCopyIndex.getRegSlot ());
445
- LR->removeSegment (DestSegment->start , NewStart);
446
- }
447
- VNInfo *DestVNI = LR->getVNInfoAt (NewStart);
406
+ assert (!DestLI.empty () && " PHIs should have nonempty LiveIntervals." );
407
+ if (DestLI.endIndex ().isDead ()) {
408
+ // A dead PHI's live range begins and ends at the start of the MBB, but
409
+ // the lowered copy, which will still be dead, needs to begin and end at
410
+ // the copy instruction.
411
+ VNInfo *OrigDestVNI = DestLI.getVNInfoAt (MBBStartIndex);
412
+ assert (OrigDestVNI && " PHI destination should be live at block entry." );
413
+ DestLI.removeSegment (MBBStartIndex, MBBStartIndex.getDeadSlot ());
414
+ DestLI.createDeadDef (DestCopyIndex.getRegSlot (),
415
+ LIS->getVNInfoAllocator ());
416
+ DestLI.removeValNo (OrigDestVNI);
417
+ } else {
418
+ // Otherwise, remove the region from the beginning of MBB to the copy
419
+ // instruction from DestReg's live interval.
420
+ DestLI.removeSegment (MBBStartIndex, DestCopyIndex.getRegSlot ());
421
+ VNInfo *DestVNI = DestLI.getVNInfoAt (DestCopyIndex.getRegSlot ());
448
422
assert (DestVNI && " PHI destination should be live at its definition." );
449
- DestVNI->def = NewStart ;
423
+ DestVNI->def = DestCopyIndex. getRegSlot () ;
450
424
}
451
425
}
452
426
@@ -641,10 +615,6 @@ void PHIElimination::LowerPHINode(MachineBasicBlock &MBB,
641
615
SlotIndex LastUseIndex = LIS->getInstructionIndex (*KillInst);
642
616
SrcLI.removeSegment (LastUseIndex.getRegSlot (),
643
617
LIS->getMBBEndIdx (&opBlock));
644
- for (auto &SR : SrcLI.subranges ()) {
645
- SR.removeSegment (LastUseIndex.getRegSlot (),
646
- LIS->getMBBEndIdx (&opBlock));
647
- }
648
618
}
649
619
}
650
620
}
0 commit comments