-
- SlotIndex Start, Stop;
- tie(Start, Stop) = Indexes->getMBBRange(BI.MBB);
- Intf.moveToBlock(BI.MBB->getNumber());
- DEBUG(dbgs() << "EB#" << Bundles->getBundle(BI.MBB->getNumber(), 0)
- << (BI.LiveIn ? (RegIn ? " => " : " -> ") : " ")
- << "BB#" << BI.MBB->getNumber()
- << (BI.LiveOut ? (RegOut ? " => " : " -> ") : " ")
- << " EB#" << Bundles->getBundle(BI.MBB->getNumber(), 1)
- << " [" << Start << ';'
- << SA->getLastSplitPoint(BI.MBB->getNumber()) << '-' << Stop
- << ") uses [" << BI.FirstUse << ';' << BI.LastUse
- << ") intf [" << Intf.first() << ';' << Intf.last() << ')');
-
- // The interference interval should either be invalid or overlap MBB.
- assert((!Intf.hasInterference() || Intf.first() < Stop)
- && "Bad interference");
- assert((!Intf.hasInterference() || Intf.last() > Start)
- && "Bad interference");
-
- // We are now ready to decide where to split in the current block. There
- // are many variables guiding the decision:
- //
- // - RegIn / RegOut: The global splitting algorithm's decisions for our
- // ingoing and outgoing bundles.
- //
- // - BI.BlockIn / BI.BlockOut: Is the live range live-in and/or live-out
- // from this block.
- //
- // - Intf.hasInterference(): Is there interference in this block.
- //
- // - Intf.first() / Inft.last(): The range of interference.
- //
- // The live range should be split such that MainIntv is live-in when RegIn
- // is set, and live-out when RegOut is set. MainIntv should never overlap
- // the interference, and the stack interval should never have more than one
- // use per block.
-
- // No splits can be inserted after LastSplitPoint, overlap instead.
- SlotIndex LastSplitPoint = Stop;
- if (BI.LiveOut)
- LastSplitPoint = SA->getLastSplitPoint(BI.MBB->getNumber());
-
- // At this point, we know that either RegIn or RegOut is set. We dealt with
- // the all-stack case above.
-
- // Blocks without interference are relatively easy.
- if (!Intf.hasInterference()) {
- DEBUG(dbgs() << ", no interference.\n");
- SE->selectIntv(MainIntv);
- // The easiest case has MainIntv live through.
- //
- // |---o---o---| Live-in, live-out.
- // ============= Use MainIntv everywhere.
- //
- SlotIndex From = Start, To = Stop;
-
- // Block entry. Reload before the first use if MainIntv is not live-in.
- //
- // |---o-- Enter on stack.
- // ____=== Reload before first use.
- //
- // | o-- Defined in block.
- // === Use MainIntv from def.
- //
- if (!RegIn)
- From = SE->enterIntvBefore(BI.FirstUse);
-
- // Block exit. Handle cases where MainIntv is not live-out.
- if (!BI.LiveOut)
- //
- // --x | Killed in block.
- // === Use MainIntv up to kill.
- //
- To = SE->leaveIntvAfter(BI.LastUse);
- else if (!RegOut) {
- //
- // --o---| Live-out on stack.
- // ===____ Use MainIntv up to last use, switch to stack.
- //
- // -----o| Live-out on stack, last use after last split point.
- // ====== Extend MainIntv to last use, overlapping.
- // \____ Copy to stack interval before last split point.
- //
- if (BI.LastUse < LastSplitPoint)
- To = SE->leaveIntvAfter(BI.LastUse);
- else {
- // The last use is after the last split point, it is probably an
- // indirect branch.
- To = SE->leaveIntvBefore(LastSplitPoint);
- // Run a double interval from the split to the last use. This makes
- // it possible to spill the complement without affecting the indirect
- // branch.
- SE->overlapIntv(To, BI.LastUse);
- }