diff options
| author | Evan Cheng <evan.cheng@apple.com> | 2009-03-23 18:24:37 +0000 |
|---|---|---|
| committer | Evan Cheng <evan.cheng@apple.com> | 2009-03-23 18:24:37 +0000 |
| commit | f858466018346e3b59acb9e3ac7dfd5ba4c0d0a9 (patch) | |
| tree | e4e577d0a629943609d240700b5968101a522108 /llvm/lib/CodeGen | |
| parent | 656711a36b2be1b2c2663f016badd59e3c3f26b3 (diff) | |
| download | bcm5719-llvm-f858466018346e3b59acb9e3ac7dfd5ba4c0d0a9.tar.gz bcm5719-llvm-f858466018346e3b59acb9e3ac7dfd5ba4c0d0a9.zip | |
Fix PR3391 and PR3864. Reg allocator infinite looping.
llvm-svn: 67544
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/LiveIntervalAnalysis.cpp | 12 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/RegAllocLinearScan.cpp | 8 |
2 files changed, 14 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/LiveIntervalAnalysis.cpp b/llvm/lib/CodeGen/LiveIntervalAnalysis.cpp index b5c21952fa3..cd6f81c6eb2 100644 --- a/llvm/lib/CodeGen/LiveIntervalAnalysis.cpp +++ b/llvm/lib/CodeGen/LiveIntervalAnalysis.cpp @@ -2214,8 +2214,9 @@ unsigned LiveIntervals::getNumConflictsWithPhysReg(const LiveInterval &li, } /// spillPhysRegAroundRegDefsUses - Spill the specified physical register -/// around all defs and uses of the specified interval. -void LiveIntervals::spillPhysRegAroundRegDefsUses(const LiveInterval &li, +/// around all defs and uses of the specified interval. Return true if it +/// was able to cut its interval. +bool LiveIntervals::spillPhysRegAroundRegDefsUses(const LiveInterval &li, unsigned PhysReg, VirtRegMap &vrm) { unsigned SpillReg = getRepresentativeReg(PhysReg); @@ -2226,6 +2227,7 @@ void LiveIntervals::spillPhysRegAroundRegDefsUses(const LiveInterval &li, assert(*AS == SpillReg || !allocatableRegs_[*AS] || tri_->isSuperRegister(*AS, SpillReg)); + bool Cut = false; LiveInterval &pli = getInterval(SpillReg); SmallPtrSet<MachineInstr*, 8> SeenMIs; for (MachineRegisterInfo::reg_iterator I = mri_->reg_begin(li.reg), @@ -2240,9 +2242,10 @@ void LiveIntervals::spillPhysRegAroundRegDefsUses(const LiveInterval &li, vrm.addEmergencySpill(SpillReg, MI); unsigned StartIdx = getLoadIndex(Index); unsigned EndIdx = getStoreIndex(Index)+1; - if (pli.isInOneLiveRange(StartIdx, EndIdx)) + if (pli.isInOneLiveRange(StartIdx, EndIdx)) { pli.removeRange(StartIdx, EndIdx); - else { + Cut = true; + } else { cerr << "Ran out of registers during register allocation!\n"; if (MI->getOpcode() == TargetInstrInfo::INLINEASM) { cerr << "Please check your inline asm statement for invalid " @@ -2260,6 +2263,7 @@ void LiveIntervals::spillPhysRegAroundRegDefsUses(const LiveInterval &li, } } } + return Cut; } LiveRange LiveIntervals::addLiveRangeToEndOfBlock(unsigned reg, diff --git a/llvm/lib/CodeGen/RegAllocLinearScan.cpp b/llvm/lib/CodeGen/RegAllocLinearScan.cpp index e8296a74775..912135a57f6 100644 --- a/llvm/lib/CodeGen/RegAllocLinearScan.cpp +++ b/llvm/lib/CodeGen/RegAllocLinearScan.cpp @@ -869,8 +869,12 @@ void RALinScan::assignRegOrStackSlotAtInterval(LiveInterval* cur) if (cur->weight == HUGE_VALF || li_->getApproximateInstructionCount(*cur) == 0) { // Spill a physical register around defs and uses. - li_->spillPhysRegAroundRegDefsUses(*cur, minReg, *vrm_); - assignRegOrStackSlotAtInterval(cur); + if (li_->spillPhysRegAroundRegDefsUses(*cur, minReg, *vrm_)) + assignRegOrStackSlotAtInterval(cur); + else { + cerr << "Ran out of registers during register allocation!\n"; + exit(1); + } return; } } |

