diff options
Diffstat (limited to 'lib/CodeGen/SplitKit.cpp')
-rw-r--r-- | lib/CodeGen/SplitKit.cpp | 226 |
1 files changed, 133 insertions, 93 deletions
diff --git a/lib/CodeGen/SplitKit.cpp b/lib/CodeGen/SplitKit.cpp index c99c3b09d88a..d639f4475301 100644 --- a/lib/CodeGen/SplitKit.cpp +++ b/lib/CodeGen/SplitKit.cpp @@ -39,6 +39,7 @@ #include "llvm/CodeGen/TargetRegisterInfo.h" #include "llvm/CodeGen/TargetSubtargetInfo.h" #include "llvm/CodeGen/VirtRegMap.h" +#include "llvm/Config/llvm-config.h" #include "llvm/IR/DebugLoc.h" #include "llvm/MC/LaneBitmask.h" #include "llvm/Support/Allocator.h" @@ -191,7 +192,7 @@ void SplitAnalysis::analyzeUses() { // I am looking at you, RegisterCoalescer! DidRepairRange = true; ++NumRepairs; - DEBUG(dbgs() << "*** Fixing inconsistent live interval! ***\n"); + LLVM_DEBUG(dbgs() << "*** Fixing inconsistent live interval! ***\n"); const_cast<LiveIntervals&>(LIS) .shrinkToUses(const_cast<LiveInterval*>(CurLI)); UseBlocks.clear(); @@ -201,10 +202,9 @@ void SplitAnalysis::analyzeUses() { assert(fixed && "Couldn't fix broken live interval"); } - DEBUG(dbgs() << "Analyze counted " - << UseSlots.size() << " instrs in " - << UseBlocks.size() << " blocks, through " - << NumThroughBlocks << " blocks.\n"); + LLVM_DEBUG(dbgs() << "Analyze counted " << UseSlots.size() << " instrs in " + << UseBlocks.size() << " blocks, through " + << NumThroughBlocks << " blocks.\n"); } /// calcLiveBlockInfo - Fill the LiveBlocks array with information about blocks @@ -491,9 +491,8 @@ VNInfo *SplitEditor::defValue(unsigned RegIdx, return VNI; } -void SplitEditor::forceRecompute(unsigned RegIdx, const VNInfo *ParentVNI) { - assert(ParentVNI && "Mapping NULL value"); - ValueForcePair &VFP = Values[std::make_pair(RegIdx, ParentVNI->id)]; +void SplitEditor::forceRecompute(unsigned RegIdx, const VNInfo &ParentVNI) { + ValueForcePair &VFP = Values[std::make_pair(RegIdx, ParentVNI.id)]; VNInfo *VNI = VFP.getPointer(); // ParentVNI was either unmapped or already complex mapped. Either way, just @@ -686,20 +685,20 @@ unsigned SplitEditor::openIntv() { void SplitEditor::selectIntv(unsigned Idx) { assert(Idx != 0 && "Cannot select the complement interval"); assert(Idx < Edit->size() && "Can only select previously opened interval"); - DEBUG(dbgs() << " selectIntv " << OpenIdx << " -> " << Idx << '\n'); + LLVM_DEBUG(dbgs() << " selectIntv " << OpenIdx << " -> " << Idx << '\n'); OpenIdx = Idx; } SlotIndex SplitEditor::enterIntvBefore(SlotIndex Idx) { assert(OpenIdx && "openIntv not called before enterIntvBefore"); - DEBUG(dbgs() << " enterIntvBefore " << Idx); + LLVM_DEBUG(dbgs() << " enterIntvBefore " << Idx); Idx = Idx.getBaseIndex(); VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(Idx); if (!ParentVNI) { - DEBUG(dbgs() << ": not live\n"); + LLVM_DEBUG(dbgs() << ": not live\n"); return Idx; } - DEBUG(dbgs() << ": valno " << ParentVNI->id << '\n'); + LLVM_DEBUG(dbgs() << ": valno " << ParentVNI->id << '\n'); MachineInstr *MI = LIS.getInstructionFromIndex(Idx); assert(MI && "enterIntvBefore called with invalid index"); @@ -709,14 +708,14 @@ SlotIndex SplitEditor::enterIntvBefore(SlotIndex Idx) { SlotIndex SplitEditor::enterIntvAfter(SlotIndex Idx) { assert(OpenIdx && "openIntv not called before enterIntvAfter"); - DEBUG(dbgs() << " enterIntvAfter " << Idx); + LLVM_DEBUG(dbgs() << " enterIntvAfter " << Idx); Idx = Idx.getBoundaryIndex(); VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(Idx); if (!ParentVNI) { - DEBUG(dbgs() << ": not live\n"); + LLVM_DEBUG(dbgs() << ": not live\n"); return Idx; } - DEBUG(dbgs() << ": valno " << ParentVNI->id << '\n'); + LLVM_DEBUG(dbgs() << ": valno " << ParentVNI->id << '\n'); MachineInstr *MI = LIS.getInstructionFromIndex(Idx); assert(MI && "enterIntvAfter called with invalid index"); @@ -729,18 +728,18 @@ SlotIndex SplitEditor::enterIntvAtEnd(MachineBasicBlock &MBB) { assert(OpenIdx && "openIntv not called before enterIntvAtEnd"); SlotIndex End = LIS.getMBBEndIdx(&MBB); SlotIndex Last = End.getPrevSlot(); - DEBUG(dbgs() << " enterIntvAtEnd " << printMBBReference(MBB) << ", " - << Last); + LLVM_DEBUG(dbgs() << " enterIntvAtEnd " << printMBBReference(MBB) << ", " + << Last); VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(Last); if (!ParentVNI) { - DEBUG(dbgs() << ": not live\n"); + LLVM_DEBUG(dbgs() << ": not live\n"); return End; } - DEBUG(dbgs() << ": valno " << ParentVNI->id); + LLVM_DEBUG(dbgs() << ": valno " << ParentVNI->id); VNInfo *VNI = defFromParent(OpenIdx, ParentVNI, Last, MBB, SA.getLastSplitPointIter(&MBB)); RegAssign.insert(VNI->def, End, OpenIdx); - DEBUG(dump()); + LLVM_DEBUG(dump()); return VNI->def; } @@ -751,23 +750,23 @@ void SplitEditor::useIntv(const MachineBasicBlock &MBB) { void SplitEditor::useIntv(SlotIndex Start, SlotIndex End) { assert(OpenIdx && "openIntv not called before useIntv"); - DEBUG(dbgs() << " useIntv [" << Start << ';' << End << "):"); + LLVM_DEBUG(dbgs() << " useIntv [" << Start << ';' << End << "):"); RegAssign.insert(Start, End, OpenIdx); - DEBUG(dump()); + LLVM_DEBUG(dump()); } SlotIndex SplitEditor::leaveIntvAfter(SlotIndex Idx) { assert(OpenIdx && "openIntv not called before leaveIntvAfter"); - DEBUG(dbgs() << " leaveIntvAfter " << Idx); + LLVM_DEBUG(dbgs() << " leaveIntvAfter " << Idx); // The interval must be live beyond the instruction at Idx. SlotIndex Boundary = Idx.getBoundaryIndex(); VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(Boundary); if (!ParentVNI) { - DEBUG(dbgs() << ": not live\n"); + LLVM_DEBUG(dbgs() << ": not live\n"); return Boundary.getNextSlot(); } - DEBUG(dbgs() << ": valno " << ParentVNI->id << '\n'); + LLVM_DEBUG(dbgs() << ": valno " << ParentVNI->id << '\n'); MachineInstr *MI = LIS.getInstructionFromIndex(Boundary); assert(MI && "No instruction at index"); @@ -777,7 +776,7 @@ SlotIndex SplitEditor::leaveIntvAfter(SlotIndex Idx) { // the source live range. The spiller also won't try to hoist this copy. if (SpillMode && !SlotIndex::isSameInstr(ParentVNI->def, Idx) && MI->readsVirtualRegister(Edit->getReg())) { - forceRecompute(0, ParentVNI); + forceRecompute(0, *ParentVNI); defFromParent(0, ParentVNI, Idx, *MI->getParent(), MI); return Idx; } @@ -789,16 +788,16 @@ SlotIndex SplitEditor::leaveIntvAfter(SlotIndex Idx) { SlotIndex SplitEditor::leaveIntvBefore(SlotIndex Idx) { assert(OpenIdx && "openIntv not called before leaveIntvBefore"); - DEBUG(dbgs() << " leaveIntvBefore " << Idx); + LLVM_DEBUG(dbgs() << " leaveIntvBefore " << Idx); // The interval must be live into the instruction at Idx. Idx = Idx.getBaseIndex(); VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(Idx); if (!ParentVNI) { - DEBUG(dbgs() << ": not live\n"); + LLVM_DEBUG(dbgs() << ": not live\n"); return Idx.getNextSlot(); } - DEBUG(dbgs() << ": valno " << ParentVNI->id << '\n'); + LLVM_DEBUG(dbgs() << ": valno " << ParentVNI->id << '\n'); MachineInstr *MI = LIS.getInstructionFromIndex(Idx); assert(MI && "No instruction at index"); @@ -809,19 +808,19 @@ SlotIndex SplitEditor::leaveIntvBefore(SlotIndex Idx) { SlotIndex SplitEditor::leaveIntvAtTop(MachineBasicBlock &MBB) { assert(OpenIdx && "openIntv not called before leaveIntvAtTop"); SlotIndex Start = LIS.getMBBStartIdx(&MBB); - DEBUG(dbgs() << " leaveIntvAtTop " << printMBBReference(MBB) << ", " - << Start); + LLVM_DEBUG(dbgs() << " leaveIntvAtTop " << printMBBReference(MBB) << ", " + << Start); VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(Start); if (!ParentVNI) { - DEBUG(dbgs() << ": not live\n"); + LLVM_DEBUG(dbgs() << ": not live\n"); return Start; } VNInfo *VNI = defFromParent(0, ParentVNI, Start, MBB, MBB.SkipPHIsLabelsAndDebug(MBB.begin())); RegAssign.insert(Start, VNI->def, OpenIdx); - DEBUG(dump()); + LLVM_DEBUG(dump()); return VNI->def; } @@ -835,10 +834,10 @@ void SplitEditor::overlapIntv(SlotIndex Start, SlotIndex End) { // The complement interval will be extended as needed by LRCalc.extend(). if (ParentVNI) - forceRecompute(0, ParentVNI); - DEBUG(dbgs() << " overlapIntv [" << Start << ';' << End << "):"); + forceRecompute(0, *ParentVNI); + LLVM_DEBUG(dbgs() << " overlapIntv [" << Start << ';' << End << "):"); RegAssign.insert(Start, End, OpenIdx); - DEBUG(dump()); + LLVM_DEBUG(dump()); } //===----------------------------------------------------------------------===// @@ -847,7 +846,7 @@ void SplitEditor::overlapIntv(SlotIndex Start, SlotIndex End) { void SplitEditor::removeBackCopies(SmallVectorImpl<VNInfo*> &Copies) { LiveInterval *LI = &LIS.getInterval(Edit->get(0)); - DEBUG(dbgs() << "Removing " << Copies.size() << " back-copies.\n"); + LLVM_DEBUG(dbgs() << "Removing " << Copies.size() << " back-copies.\n"); RegAssignMap::iterator AssignI; AssignI.setMap(RegAssign); @@ -860,9 +859,9 @@ void SplitEditor::removeBackCopies(SmallVectorImpl<VNInfo*> &Copies) { MachineBasicBlock::iterator MBBI(MI); bool AtBegin; do AtBegin = MBBI == MBB->begin(); - while (!AtBegin && (--MBBI)->isDebugValue()); + while (!AtBegin && (--MBBI)->isDebugInstr()); - DEBUG(dbgs() << "Removing " << Def << '\t' << *MI); + LLVM_DEBUG(dbgs() << "Removing " << Def << '\t' << *MI); LIS.removeVRegDefAt(*LI, Def); LIS.RemoveMachineInstrFromMaps(*MI); MI->eraseFromParent(); @@ -877,11 +876,12 @@ void SplitEditor::removeBackCopies(SmallVectorImpl<VNInfo*> &Copies) { continue; unsigned RegIdx = AssignI.value(); if (AtBegin || !MBBI->readsVirtualRegister(Edit->getReg())) { - DEBUG(dbgs() << " cannot find simple kill of RegIdx " << RegIdx << '\n'); - forceRecompute(RegIdx, Edit->getParent().getVNInfoAt(Def)); + LLVM_DEBUG(dbgs() << " cannot find simple kill of RegIdx " << RegIdx + << '\n'); + forceRecompute(RegIdx, *Edit->getParent().getVNInfoAt(Def)); } else { SlotIndex Kill = LIS.getInstructionIndex(*MBBI).getRegSlot(); - DEBUG(dbgs() << " move kill to " << Kill << '\t' << *MBBI); + LLVM_DEBUG(dbgs() << " move kill to " << Kill << '\t' << *MBBI); AssignI.setStop(Kill); } } @@ -908,15 +908,17 @@ SplitEditor::findShallowDominator(MachineBasicBlock *MBB, // MBB isn't in a loop, it doesn't get any better. All dominators have a // higher frequency by definition. if (!Loop) { - DEBUG(dbgs() << "Def in " << printMBBReference(*DefMBB) << " dominates " - << printMBBReference(*MBB) << " at depth 0\n"); + LLVM_DEBUG(dbgs() << "Def in " << printMBBReference(*DefMBB) + << " dominates " << printMBBReference(*MBB) + << " at depth 0\n"); return MBB; } // We'll never be able to exit the DefLoop. if (Loop == DefLoop) { - DEBUG(dbgs() << "Def in " << printMBBReference(*DefMBB) << " dominates " - << printMBBReference(*MBB) << " in the same loop\n"); + LLVM_DEBUG(dbgs() << "Def in " << printMBBReference(*DefMBB) + << " dominates " << printMBBReference(*MBB) + << " in the same loop\n"); return MBB; } @@ -925,8 +927,9 @@ SplitEditor::findShallowDominator(MachineBasicBlock *MBB, if (Depth < BestDepth) { BestMBB = MBB; BestDepth = Depth; - DEBUG(dbgs() << "Def in " << printMBBReference(*DefMBB) << " dominates " - << printMBBReference(*MBB) << " at depth " << Depth << '\n'); + LLVM_DEBUG(dbgs() << "Def in " << printMBBReference(*DefMBB) + << " dominates " << printMBBReference(*MBB) + << " at depth " << Depth << '\n'); } // Leave loop by going to the immediate dominator of the loop header. @@ -982,7 +985,7 @@ void SplitEditor::computeRedundantBackCopies( } } if (!DominatedVNIs.empty()) { - forceRecompute(0, ParentVNI); + forceRecompute(0, *ParentVNI); for (auto VNI : DominatedVNIs) { BackCopies.push_back(VNI); } @@ -1032,14 +1035,14 @@ void SplitEditor::hoistCopies() { // instruction in the complement range. All other copies of ParentVNI // should be eliminated. if (VNI->def == ParentVNI->def) { - DEBUG(dbgs() << "Direct complement def at " << VNI->def << '\n'); + LLVM_DEBUG(dbgs() << "Direct complement def at " << VNI->def << '\n'); Dom = DomPair(ValMBB, VNI->def); continue; } // Skip the singly mapped values. There is nothing to gain from hoisting a // single back-copy. if (Values.lookup(std::make_pair(0, ParentVNI->id)).getPointer()) { - DEBUG(dbgs() << "Single complement def at " << VNI->def << '\n'); + LLVM_DEBUG(dbgs() << "Single complement def at " << VNI->def << '\n'); continue; } @@ -1063,10 +1066,11 @@ void SplitEditor::hoistCopies() { Costs[ParentVNI->id] += MBFI.getBlockFreq(ValMBB); } - DEBUG(dbgs() << "Multi-mapped complement " << VNI->id << '@' << VNI->def - << " for parent " << ParentVNI->id << '@' << ParentVNI->def - << " hoist to " << printMBBReference(*Dom.first) << ' ' - << Dom.second << '\n'); + LLVM_DEBUG(dbgs() << "Multi-mapped complement " << VNI->id << '@' + << VNI->def << " for parent " << ParentVNI->id << '@' + << ParentVNI->def << " hoist to " + << printMBBReference(*Dom.first) << ' ' << Dom.second + << '\n'); } // Insert the hoisted copies. @@ -1102,7 +1106,7 @@ void SplitEditor::hoistCopies() { NotToHoistSet.count(ParentVNI->id)) continue; BackCopies.push_back(VNI); - forceRecompute(0, ParentVNI); + forceRecompute(0, *ParentVNI); } // If it is not beneficial to hoist all the BackCopies, simply remove @@ -1119,7 +1123,7 @@ bool SplitEditor::transferValues() { bool Skipped = false; RegAssignMap::const_iterator AssignI = RegAssign.begin(); for (const LiveRange::Segment &S : Edit->getParent()) { - DEBUG(dbgs() << " blit " << S << ':'); + LLVM_DEBUG(dbgs() << " blit " << S << ':'); VNInfo *ParentVNI = S.valno; // RegAssign has holes where RegIdx 0 should be used. SlotIndex Start = S.start; @@ -1141,14 +1145,14 @@ bool SplitEditor::transferValues() { } // The interval [Start;End) is continuously mapped to RegIdx, ParentVNI. - DEBUG(dbgs() << " [" << Start << ';' << End << ")=" << RegIdx - << '(' << printReg(Edit->get(RegIdx)) << ')'); + LLVM_DEBUG(dbgs() << " [" << Start << ';' << End << ")=" << RegIdx << '(' + << printReg(Edit->get(RegIdx)) << ')'); LiveInterval &LI = LIS.getInterval(Edit->get(RegIdx)); // Check for a simply defined value that can be blitted directly. ValueForcePair VFP = Values.lookup(std::make_pair(RegIdx, ParentVNI->id)); if (VNInfo *VNI = VFP.getPointer()) { - DEBUG(dbgs() << ':' << VNI->id); + LLVM_DEBUG(dbgs() << ':' << VNI->id); LI.addSegment(LiveInterval::Segment(Start, End, VNI)); Start = End; continue; @@ -1156,7 +1160,7 @@ bool SplitEditor::transferValues() { // Skip values with forced recomputation. if (VFP.getInt()) { - DEBUG(dbgs() << "(recalc)"); + LLVM_DEBUG(dbgs() << "(recalc)"); Skipped = true; Start = End; continue; @@ -1175,7 +1179,7 @@ bool SplitEditor::transferValues() { if (Start != BlockStart) { VNInfo *VNI = LI.extendInBlock(BlockStart, std::min(BlockEnd, End)); assert(VNI && "Missing def for complex mapped value"); - DEBUG(dbgs() << ':' << VNI->id << "*" << printMBBReference(*MBB)); + LLVM_DEBUG(dbgs() << ':' << VNI->id << "*" << printMBBReference(*MBB)); // MBB has its own def. Is it also live-out? if (BlockEnd <= End) LRC.setLiveOutValue(&*MBB, VNI); @@ -1188,7 +1192,7 @@ bool SplitEditor::transferValues() { // Handle the live-in blocks covered by [Start;End). assert(Start <= BlockStart && "Expected live-in block"); while (BlockStart < End) { - DEBUG(dbgs() << ">" << printMBBReference(*MBB)); + LLVM_DEBUG(dbgs() << ">" << printMBBReference(*MBB)); BlockEnd = LIS.getMBBEndIdx(&*MBB); if (BlockStart == ParentVNI->def) { // This block has the def of a parent PHI, so it isn't live-in. @@ -1213,7 +1217,7 @@ bool SplitEditor::transferValues() { } Start = End; } while (Start != S.end); - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << '\n'); } LRCalc[0].calculateValues(); @@ -1315,7 +1319,7 @@ void SplitEditor::rewriteAssigned(bool ExtendRanges) { ++RI; // LiveDebugVariables should have handled all DBG_VALUE instructions. if (MI->isDebugValue()) { - DEBUG(dbgs() << "Zapping " << *MI); + LLVM_DEBUG(dbgs() << "Zapping " << *MI); MO.setReg(0); continue; } @@ -1331,8 +1335,8 @@ void SplitEditor::rewriteAssigned(bool ExtendRanges) { unsigned RegIdx = RegAssign.lookup(Idx); LiveInterval &LI = LIS.getInterval(Edit->get(RegIdx)); MO.setReg(LI.reg); - DEBUG(dbgs() << " rewr " << printMBBReference(*MI->getParent()) << '\t' - << Idx << ':' << RegIdx << '\t' << *MI); + LLVM_DEBUG(dbgs() << " rewr " << printMBBReference(*MI->getParent()) + << '\t' << Idx << ':' << RegIdx << '\t' << *MI); // Extend liveness to Idx if the instruction reads reg. if (!ExtendRanges || MO.isUndef()) @@ -1417,7 +1421,7 @@ void SplitEditor::deleteRematVictims() { if (!MI->allDefsAreDead()) continue; - DEBUG(dbgs() << "All defs dead: " << *MI); + LLVM_DEBUG(dbgs() << "All defs dead: " << *MI); Dead.push_back(MI); } } @@ -1428,6 +1432,41 @@ void SplitEditor::deleteRematVictims() { Edit->eliminateDeadDefs(Dead, None, &AA); } +void SplitEditor::forceRecomputeVNI(const VNInfo &ParentVNI) { + // Fast-path for common case. + if (!ParentVNI.isPHIDef()) { + for (unsigned I = 0, E = Edit->size(); I != E; ++I) + forceRecompute(I, ParentVNI); + return; + } + + // Trace value through phis. + SmallPtrSet<const VNInfo *, 8> Visited; ///< whether VNI was/is in worklist. + SmallVector<const VNInfo *, 4> WorkList; + Visited.insert(&ParentVNI); + WorkList.push_back(&ParentVNI); + + const LiveInterval &ParentLI = Edit->getParent(); + const SlotIndexes &Indexes = *LIS.getSlotIndexes(); + do { + const VNInfo &VNI = *WorkList.back(); + WorkList.pop_back(); + for (unsigned I = 0, E = Edit->size(); I != E; ++I) + forceRecompute(I, VNI); + if (!VNI.isPHIDef()) + continue; + + MachineBasicBlock &MBB = *Indexes.getMBBFromIndex(VNI.def); + for (const MachineBasicBlock *Pred : MBB.predecessors()) { + SlotIndex PredEnd = Indexes.getMBBEndIdx(Pred); + VNInfo *PredVNI = ParentLI.getVNInfoBefore(PredEnd); + assert(PredVNI && "Value available in PhiVNI predecessor"); + if (Visited.insert(PredVNI).second) + WorkList.push_back(PredVNI); + } + } while(!WorkList.empty()); +} + void SplitEditor::finish(SmallVectorImpl<unsigned> *LRMap) { ++NumFinished; @@ -1444,8 +1483,7 @@ void SplitEditor::finish(SmallVectorImpl<unsigned> *LRMap) { // Force rematted values to be recomputed everywhere. // The new live ranges may be truncated. if (Edit->didRematerialize(ParentVNI)) - for (unsigned i = 0, e = Edit->size(); i != e; ++i) - forceRecompute(i, ParentVNI); + forceRecomputeVNI(*ParentVNI); } // Hoist back-copies to the complement interval when in spill mode. @@ -1565,9 +1603,9 @@ void SplitEditor::splitLiveThroughBlock(unsigned MBBNum, SlotIndex Start, Stop; std::tie(Start, Stop) = LIS.getSlotIndexes()->getMBBRange(MBBNum); - DEBUG(dbgs() << "%bb." << MBBNum << " [" << Start << ';' << Stop << ") intf " - << LeaveBefore << '-' << EnterAfter << ", live-through " - << IntvIn << " -> " << IntvOut); + LLVM_DEBUG(dbgs() << "%bb." << MBBNum << " [" << Start << ';' << Stop + << ") intf " << LeaveBefore << '-' << EnterAfter + << ", live-through " << IntvIn << " -> " << IntvOut); assert((IntvIn || IntvOut) && "Use splitSingleBlock for isolated blocks"); @@ -1578,7 +1616,7 @@ void SplitEditor::splitLiveThroughBlock(unsigned MBBNum, MachineBasicBlock *MBB = VRM.getMachineFunction().getBlockNumbered(MBBNum); if (!IntvOut) { - DEBUG(dbgs() << ", spill on entry.\n"); + LLVM_DEBUG(dbgs() << ", spill on entry.\n"); // // <<<<<<<<< Possible LeaveBefore interference. // |-----------| Live through. @@ -1592,7 +1630,7 @@ void SplitEditor::splitLiveThroughBlock(unsigned MBBNum, } if (!IntvIn) { - DEBUG(dbgs() << ", reload on exit.\n"); + LLVM_DEBUG(dbgs() << ", reload on exit.\n"); // // >>>>>>> Possible EnterAfter interference. // |-----------| Live through. @@ -1606,7 +1644,7 @@ void SplitEditor::splitLiveThroughBlock(unsigned MBBNum, } if (IntvIn == IntvOut && !LeaveBefore && !EnterAfter) { - DEBUG(dbgs() << ", straight through.\n"); + LLVM_DEBUG(dbgs() << ", straight through.\n"); // // |-----------| Live through. // ------------- Straight through, same intv, no interference. @@ -1622,7 +1660,7 @@ void SplitEditor::splitLiveThroughBlock(unsigned MBBNum, if (IntvIn != IntvOut && (!LeaveBefore || !EnterAfter || LeaveBefore.getBaseIndex() > EnterAfter.getBoundaryIndex())) { - DEBUG(dbgs() << ", switch avoiding interference.\n"); + LLVM_DEBUG(dbgs() << ", switch avoiding interference.\n"); // // >>>> <<<< Non-overlapping EnterAfter/LeaveBefore interference. // |-----------| Live through. @@ -1643,7 +1681,7 @@ void SplitEditor::splitLiveThroughBlock(unsigned MBBNum, return; } - DEBUG(dbgs() << ", create local intv for interference.\n"); + LLVM_DEBUG(dbgs() << ", create local intv for interference.\n"); // // >>><><><><<<< Overlapping EnterAfter/LeaveBefore interference. // |-----------| Live through. @@ -1667,17 +1705,18 @@ void SplitEditor::splitRegInBlock(const SplitAnalysis::BlockInfo &BI, SlotIndex Start, Stop; std::tie(Start, Stop) = LIS.getSlotIndexes()->getMBBRange(BI.MBB); - DEBUG(dbgs() << printMBBReference(*BI.MBB) << " [" << Start << ';' << Stop - << "), uses " << BI.FirstInstr << '-' << BI.LastInstr - << ", reg-in " << IntvIn << ", leave before " << LeaveBefore - << (BI.LiveOut ? ", stack-out" : ", killed in block")); + LLVM_DEBUG(dbgs() << printMBBReference(*BI.MBB) << " [" << Start << ';' + << Stop << "), uses " << BI.FirstInstr << '-' + << BI.LastInstr << ", reg-in " << IntvIn + << ", leave before " << LeaveBefore + << (BI.LiveOut ? ", stack-out" : ", killed in block")); assert(IntvIn && "Must have register in"); assert(BI.LiveIn && "Must be live-in"); assert((!LeaveBefore || LeaveBefore > Start) && "Bad interference"); if (!BI.LiveOut && (!LeaveBefore || LeaveBefore >= BI.LastInstr)) { - DEBUG(dbgs() << " before interference.\n"); + LLVM_DEBUG(dbgs() << " before interference.\n"); // // <<< Interference after kill. // |---o---x | Killed in block. @@ -1702,13 +1741,13 @@ void SplitEditor::splitRegInBlock(const SplitAnalysis::BlockInfo &BI, // \_____ Stack interval is live-out. // if (BI.LastInstr < LSP) { - DEBUG(dbgs() << ", spill after last use before interference.\n"); + LLVM_DEBUG(dbgs() << ", spill after last use before interference.\n"); selectIntv(IntvIn); SlotIndex Idx = leaveIntvAfter(BI.LastInstr); useIntv(Start, Idx); assert((!LeaveBefore || Idx <= LeaveBefore) && "Interference"); } else { - DEBUG(dbgs() << ", spill before last split point.\n"); + LLVM_DEBUG(dbgs() << ", spill before last split point.\n"); selectIntv(IntvIn); SlotIndex Idx = leaveIntvBefore(LSP); overlapIntv(Idx, BI.LastInstr); @@ -1723,7 +1762,7 @@ void SplitEditor::splitRegInBlock(const SplitAnalysis::BlockInfo &BI, // different register. unsigned LocalIntv = openIntv(); (void)LocalIntv; - DEBUG(dbgs() << ", creating local interval " << LocalIntv << ".\n"); + LLVM_DEBUG(dbgs() << ", creating local interval " << LocalIntv << ".\n"); if (!BI.LiveOut || BI.LastInstr < LSP) { // @@ -1759,10 +1798,11 @@ void SplitEditor::splitRegOutBlock(const SplitAnalysis::BlockInfo &BI, SlotIndex Start, Stop; std::tie(Start, Stop) = LIS.getSlotIndexes()->getMBBRange(BI.MBB); - DEBUG(dbgs() << printMBBReference(*BI.MBB) << " [" << Start << ';' << Stop - << "), uses " << BI.FirstInstr << '-' << BI.LastInstr - << ", reg-out " << IntvOut << ", enter after " << EnterAfter - << (BI.LiveIn ? ", stack-in" : ", defined in block")); + LLVM_DEBUG(dbgs() << printMBBReference(*BI.MBB) << " [" << Start << ';' + << Stop << "), uses " << BI.FirstInstr << '-' + << BI.LastInstr << ", reg-out " << IntvOut + << ", enter after " << EnterAfter + << (BI.LiveIn ? ", stack-in" : ", defined in block")); SlotIndex LSP = SA.getLastSplitPoint(BI.MBB->getNumber()); @@ -1771,7 +1811,7 @@ void SplitEditor::splitRegOutBlock(const SplitAnalysis::BlockInfo &BI, assert((!EnterAfter || EnterAfter < LSP) && "Bad interference"); if (!BI.LiveIn && (!EnterAfter || EnterAfter <= BI.FirstInstr)) { - DEBUG(dbgs() << " after interference.\n"); + LLVM_DEBUG(dbgs() << " after interference.\n"); // // >>>> Interference before def. // | o---o---| Defined in block. @@ -1783,7 +1823,7 @@ void SplitEditor::splitRegOutBlock(const SplitAnalysis::BlockInfo &BI, } if (!EnterAfter || EnterAfter < BI.FirstInstr.getBaseIndex()) { - DEBUG(dbgs() << ", reload after interference.\n"); + LLVM_DEBUG(dbgs() << ", reload after interference.\n"); // // >>>> Interference before def. // |---o---o---| Live-through, stack-in. @@ -1799,7 +1839,7 @@ void SplitEditor::splitRegOutBlock(const SplitAnalysis::BlockInfo &BI, // The interference is overlapping somewhere we wanted to use IntvOut. That // means we need to create a local interval that can be allocated a // different register. - DEBUG(dbgs() << ", interference overlaps uses.\n"); + LLVM_DEBUG(dbgs() << ", interference overlaps uses.\n"); // // >>>>>>> Interference overlapping uses. // |---o---o---| Live-through, stack-in. |