diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 10:51:19 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 10:51:19 +0000 |
commit | eb11fae6d08f479c0799db45860a98af528fa6e7 (patch) | |
tree | 44d492a50c8c1a7eb8e2d17ea3360ec4d066f042 /lib/CodeGen/LiveRangeEdit.cpp | |
parent | b8a2042aa938069e862750553db0e4d82d25822c (diff) |
Notes
Diffstat (limited to 'lib/CodeGen/LiveRangeEdit.cpp')
-rw-r--r-- | lib/CodeGen/LiveRangeEdit.cpp | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/lib/CodeGen/LiveRangeEdit.cpp b/lib/CodeGen/LiveRangeEdit.cpp index 86cfbd87f5b1..8dfe8b68c3af 100644 --- a/lib/CodeGen/LiveRangeEdit.cpp +++ b/lib/CodeGen/LiveRangeEdit.cpp @@ -31,21 +31,24 @@ STATISTIC(NumFracRanges, "Number of live ranges fractured by DCE"); void LiveRangeEdit::Delegate::anchor() { } -LiveInterval &LiveRangeEdit::createEmptyIntervalFrom(unsigned OldReg) { +LiveInterval &LiveRangeEdit::createEmptyIntervalFrom(unsigned OldReg, + bool createSubRanges) { unsigned VReg = MRI.createVirtualRegister(MRI.getRegClass(OldReg)); - if (VRM) { + if (VRM) VRM->setIsSplitFromReg(VReg, VRM->getOriginal(OldReg)); - } + LiveInterval &LI = LIS.createEmptyInterval(VReg); if (Parent && !Parent->isSpillable()) LI.markNotSpillable(); - // Create empty subranges if the OldReg's interval has them. Do not create - // the main range here---it will be constructed later after the subranges - // have been finalized. - LiveInterval &OldLI = LIS.getInterval(OldReg); - VNInfo::Allocator &Alloc = LIS.getVNInfoAllocator(); - for (LiveInterval::SubRange &S : OldLI.subranges()) - LI.createSubRange(Alloc, S.LaneMask); + if (createSubRanges) { + // Create empty subranges if the OldReg's interval has them. Do not create + // the main range here---it will be constructed later after the subranges + // have been finalized. + LiveInterval &OldLI = LIS.getInterval(OldReg); + VNInfo::Allocator &Alloc = LIS.getVNInfoAllocator(); + for (LiveInterval::SubRange &S : OldLI.subranges()) + LI.createSubRange(Alloc, S.LaneMask); + } return LI; } @@ -217,8 +220,8 @@ bool LiveRangeEdit::foldAsLoad(LiveInterval *LI, if (!DefMI->isSafeToMove(nullptr, SawStore)) return false; - DEBUG(dbgs() << "Try to fold single def: " << *DefMI - << " into single use: " << *UseMI); + LLVM_DEBUG(dbgs() << "Try to fold single def: " << *DefMI + << " into single use: " << *UseMI); SmallVector<unsigned, 8> Ops; if (UseMI->readsWritesVirtualRegister(LI->reg, &Ops).second) @@ -227,7 +230,7 @@ bool LiveRangeEdit::foldAsLoad(LiveInterval *LI, MachineInstr *FoldMI = TII.foldMemoryOperand(*UseMI, Ops, *DefMI, &LIS); if (!FoldMI) return false; - DEBUG(dbgs() << " folded: " << *FoldMI); + LLVM_DEBUG(dbgs() << " folded: " << *FoldMI); LIS.ReplaceMachineInstrInMaps(*UseMI, *FoldMI); UseMI->eraseFromParent(); DefMI->addRegisterDead(LI->reg, nullptr); @@ -264,18 +267,18 @@ void LiveRangeEdit::eliminateDeadDef(MachineInstr *MI, ToShrinkSet &ToShrink, } // Never delete inline asm. if (MI->isInlineAsm()) { - DEBUG(dbgs() << "Won't delete: " << Idx << '\t' << *MI); + LLVM_DEBUG(dbgs() << "Won't delete: " << Idx << '\t' << *MI); return; } // Use the same criteria as DeadMachineInstructionElim. bool SawStore = false; if (!MI->isSafeToMove(nullptr, SawStore)) { - DEBUG(dbgs() << "Can't delete: " << Idx << '\t' << *MI); + LLVM_DEBUG(dbgs() << "Can't delete: " << Idx << '\t' << *MI); return; } - DEBUG(dbgs() << "Deleting dead def " << Idx << '\t' << *MI); + LLVM_DEBUG(dbgs() << "Deleting dead def " << Idx << '\t' << *MI); // Collect virtual registers to be erased after MI is gone. SmallVector<unsigned, 8> RegsToErase; @@ -349,7 +352,7 @@ void LiveRangeEdit::eliminateDeadDef(MachineInstr *MI, ToShrinkSet &ToShrink, continue; MI->RemoveOperand(i-1); } - DEBUG(dbgs() << "Converted physregs to:\t" << *MI); + LLVM_DEBUG(dbgs() << "Converted physregs to:\t" << *MI); } else { // If the dest of MI is an original reg and MI is reMaterializable, // don't delete the inst. Replace the dest with a new reg, and keep @@ -357,12 +360,11 @@ void LiveRangeEdit::eliminateDeadDef(MachineInstr *MI, ToShrinkSet &ToShrink, // LiveRangeEdit::DeadRemats and will be deleted after all the // allocations of the func are done. if (isOrigDef && DeadRemats && TII.isTriviallyReMaterializable(*MI, AA)) { - LiveInterval &NewLI = createEmptyIntervalFrom(Dest); - NewLI.removeEmptySubRanges(); + LiveInterval &NewLI = createEmptyIntervalFrom(Dest, false); VNInfo *VNI = NewLI.getNextValue(Idx, LIS.getVNInfoAllocator()); NewLI.addSegment(LiveInterval::Segment(Idx, Idx.getDeadSlot(), VNI)); pop_back(); - markDeadRemat(MI); + DeadRemats->insert(MI); const TargetRegisterInfo &TRI = *MRI.getTargetRegisterInfo(); MI->substituteRegister(Dest, NewLI.reg, 0, TRI); MI->getOperand(0).setIsDead(true); @@ -463,7 +465,7 @@ LiveRangeEdit::calculateRegClassAndHint(MachineFunction &MF, for (unsigned I = 0, Size = size(); I < Size; ++I) { LiveInterval &LI = LIS.getInterval(get(I)); if (MRI.recomputeRegClass(LI.reg)) - DEBUG({ + LLVM_DEBUG({ const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo(); dbgs() << "Inflated " << printReg(LI.reg) << " to " << TRI->getRegClassName(MRI.getRegClass(LI.reg)) << '\n'; |