diff options
author | Cameron Zwarich <zwarich@apple.com> | 2013-02-17 00:10:44 +0000 |
---|---|---|
committer | Cameron Zwarich <zwarich@apple.com> | 2013-02-17 00:10:44 +0000 |
commit | f0b2535344e8c9e2912da78010918a44c5a18cab (patch) | |
tree | 74335c2750bc468334a70f31581aee40cf255c0d /lib/CodeGen/LiveIntervalAnalysis.cpp | |
parent | cc54889cd58322b8766525f43cc1f7cb52e4692e (diff) |
Add support for updating the LiveIntervals of registers used by 'exotic'
terminators that actually have register uses when splitting critical edges.
This commit also introduces a method repairIntervalsInRange() on LiveIntervals,
which allows for repairing LiveIntervals in a small range after an arbitrary
target hook modifies, inserts, and removes instructions. It's pretty limited
right now, but I hope to extend it to support all of the things that are done
by the convertToThreeAddress() target hooks.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175382 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/LiveIntervalAnalysis.cpp')
-rw-r--r-- | lib/CodeGen/LiveIntervalAnalysis.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp index 0d4ec11266..3c67be5e8f 100644 --- a/lib/CodeGen/LiveIntervalAnalysis.cpp +++ b/lib/CodeGen/LiveIntervalAnalysis.cpp @@ -1032,3 +1032,39 @@ void LiveIntervals::handleMoveIntoBundle(MachineInstr* MI, HMEditor HME(*this, *MRI, *TRI, OldIndex, NewIndex, UpdateFlags); HME.updateAllRanges(MI); } + +void +LiveIntervals::repairIntervalsInRange(MachineBasicBlock *MBB, + MachineBasicBlock::reverse_iterator RBegin, + MachineBasicBlock::reverse_iterator REnd, + SmallVectorImpl<unsigned> &OrigRegs) { + for (unsigned i = 0, e = OrigRegs.size(); i != e; ++i) { + unsigned Reg = OrigRegs[i]; + if (!TargetRegisterInfo::isVirtualRegister(Reg)) + continue; + + LiveInterval &LI = getInterval(Reg); + SlotIndex startIdx = (REnd == MBB->rend()) ? getMBBStartIdx(MBB) + : getInstructionIndex(&*REnd); + for (MachineBasicBlock::reverse_iterator I = RBegin; I != REnd; ++I) { + MachineInstr *MI = &*I; + SlotIndex instrIdx = getInstructionIndex(MI); + + for (MachineInstr::mop_iterator OI = MI->operands_begin(), + OE = MI->operands_end(); OI != OE; ++OI) { + const MachineOperand &MO = *OI; + if (!MO.isReg() || MO.getReg() != Reg) + continue; + + assert(MO.isUse() && "Register defs are not yet supported."); + + if (!LI.liveAt(instrIdx)) { + LiveRange *LR = LI.getLiveRangeContaining(startIdx.getRegSlot()); + assert(LR && "Used registers must be live-in."); + LR->end = instrIdx.getRegSlot(); + break; + } + } + } + } +} |