diff options
author | Evan Cheng <evan.cheng@apple.com> | 2006-05-11 07:29:24 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2006-05-11 07:29:24 +0000 |
commit | 993141402f57b4d4cbb7f8a3113f19c61688f9b7 (patch) | |
tree | 248f6a62f93cef5cef59673792748e14ed44c0dd /lib/CodeGen/LiveIntervalAnalysis.cpp | |
parent | 5d02eafaf250931838e77a6f5741e3738764e908 (diff) |
Set weight of zero length intervals to infinite to prevent them from being
spilled.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28220 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/LiveIntervalAnalysis.cpp')
-rw-r--r-- | lib/CodeGen/LiveIntervalAnalysis.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp index 946d80de6b..0bff34cef2 100644 --- a/lib/CodeGen/LiveIntervalAnalysis.cpp +++ b/lib/CodeGen/LiveIntervalAnalysis.cpp @@ -80,6 +80,15 @@ void LiveIntervals::releaseMemory() } +static bool isZeroLengthInterval(LiveInterval *li) { + for (LiveInterval::Ranges::const_iterator + i = li->ranges.begin(), e = li->ranges.end(); i != e; ++i) + if (i->end - i->start > LiveIntervals::InstrSlots::NUM) + return false; + return true; +} + + /// runOnMachineFunction - Register allocate the whole function /// bool LiveIntervals::runOnMachineFunction(MachineFunction &fn) { @@ -199,6 +208,16 @@ bool LiveIntervals::runOnMachineFunction(MachineFunction &fn) { } } + for (iterator I = begin(), E = end(); I != E; ++I) { + LiveInterval &li = I->second; + if (MRegisterInfo::isVirtualRegister(li.reg)) + // If the live interval legnth is essentially zero, i.e. in every live + // range the use follows def immediately, it doesn't make sense to spill + // it and hope it will be easier to allocate for this li. + if (isZeroLengthInterval(&li)) + li.weight = float(HUGE_VAL); + } + DEBUG(dump()); return true; } |