diff options
author | Cameron Zwarich <zwarich@apple.com> | 2013-02-20 06:46:48 +0000 |
---|---|---|
committer | Cameron Zwarich <zwarich@apple.com> | 2013-02-20 06:46:48 +0000 |
commit | 9030fc22dd73684901ecb749c9688e289bd1a777 (patch) | |
tree | 80617332dbbc87af3474cc7a8ed7e7f375df0afe /lib/CodeGen/LiveIntervalAnalysis.cpp | |
parent | 6cf93d740a600024f2de924614a4d4d0dc1cb852 (diff) |
Add support to the two-address pass for updating LiveIntervals in many of the
common transformations. This includes updating repairIntervalsInRange() to
handle more cases.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175604 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/LiveIntervalAnalysis.cpp')
-rw-r--r-- | lib/CodeGen/LiveIntervalAnalysis.cpp | 51 |
1 files changed, 40 insertions, 11 deletions
diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp index 7b1eed2a34..8177db6194 100644 --- a/lib/CodeGen/LiveIntervalAnalysis.cpp +++ b/lib/CodeGen/LiveIntervalAnalysis.cpp @@ -1038,20 +1038,36 @@ LiveIntervals::repairIntervalsInRange(MachineBasicBlock *MBB, MachineBasicBlock::iterator Begin, MachineBasicBlock::iterator End, ArrayRef<unsigned> OrigRegs) { - SlotIndex startIdx; - if (Begin == MBB->begin()) - startIdx = getMBBStartIdx(MBB); + SlotIndex endIdx; + if (End == MBB->end()) + endIdx = getMBBEndIdx(MBB).getPrevSlot(); else - startIdx = getInstructionIndex(prior(Begin)).getRegSlot(); + endIdx = getInstructionIndex(End); Indexes->repairIndexesInRange(MBB, Begin, End); + for (MachineBasicBlock::iterator I = End; I != Begin;) { + --I; + MachineInstr *MI = I; + for (MachineInstr::const_mop_iterator MOI = MI->operands_begin(), + MOE = MI->operands_end(); MOI != MOE; ++MOI) { + if (MOI->isReg() && + TargetRegisterInfo::isVirtualRegister(MOI->getReg()) && + !hasInterval(MOI->getReg())) { + LiveInterval &LI = getOrCreateInterval(MOI->getReg()); + computeVirtRegInterval(&LI); + } + } + } + for (unsigned i = 0, e = OrigRegs.size(); i != e; ++i) { unsigned Reg = OrigRegs[i]; if (!TargetRegisterInfo::isVirtualRegister(Reg)) continue; LiveInterval &LI = getInterval(Reg); + LiveInterval::iterator LII = LI.FindLiveRangeContaining(endIdx); + for (MachineBasicBlock::iterator I = End; I != Begin;) { --I; MachineInstr *MI = I; @@ -1063,13 +1079,26 @@ LiveIntervals::repairIntervalsInRange(MachineBasicBlock *MBB, 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); - assert(LR && "Used registers must be live-in."); - LR->end = instrIdx.getRegSlot(); - break; + if (MO.isDef()) { + assert(LII != LI.end() && + "Dead register defs are not yet supported."); + if (!Indexes->getInstructionFromIndex(LII->start)) { + LII->start = instrIdx.getRegSlot(); + LII->valno->def = instrIdx.getRegSlot(); + } else if (LII->start != instrIdx.getRegSlot()) { + VNInfo *VNI = LI.getNextValue(instrIdx.getRegSlot(), VNInfoAllocator); + LiveRange LR = LiveRange(instrIdx.getRegSlot(), LII->start, VNI); + LII = LI.addRange(LR); + } + } else if (MO.isUse()) { + if (LII == LI.end()) + --LII; + + assert(LII->start < instrIdx && + "Registers with multiple used live ranges are not yet supported."); + SlotIndex endIdx = LII->end; + if (!endIdx.isBlock() && !Indexes->getInstructionFromIndex(endIdx)) + LII->end = instrIdx.getRegSlot(); } } } |