summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/RegAllocGreedy.cpp
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2014-02-26 22:07:26 +0000
committerAndrew Trick <atrick@apple.com>2014-02-26 22:07:26 +0000
commit52a00936b4862096ae073c8c9391a3bae44c2e8a (patch)
tree4961d59b104aeee6a8d222a1be756e58937389cd /llvm/lib/CodeGen/RegAllocGreedy.cpp
parent0140ce483fe21404b8ad0aed59521b33cb16440a (diff)
downloadbcm5719-llvm-52a00936b4862096ae073c8c9391a3bae44c2e8a.tar.gz
bcm5719-llvm-52a00936b4862096ae073c8c9391a3bae44c2e8a.zip
Add a limit to the heuristic that register allocates instructions in local order.
This handles pathological cases in which we see 2x increase in spill code for large blocks (~50k instructions). I don't have a unit test for this behavior. Fixes rdar://16072279. llvm-svn: 202304
Diffstat (limited to 'llvm/lib/CodeGen/RegAllocGreedy.cpp')
-rw-r--r--llvm/lib/CodeGen/RegAllocGreedy.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/RegAllocGreedy.cpp b/llvm/lib/CodeGen/RegAllocGreedy.cpp
index 19a9e3182e7..6e6a594479e 100644
--- a/llvm/lib/CodeGen/RegAllocGreedy.cpp
+++ b/llvm/lib/CodeGen/RegAllocGreedy.cpp
@@ -454,12 +454,18 @@ void RAGreedy::enqueue(PQueue &CurQueue, LiveInterval *LI) {
// everything else has been allocated.
Prio = Size;
} else {
- if (ExtraRegInfo[Reg].Stage == RS_Assign && !LI->empty() &&
+ // Giant live ranges fall back to the global assignment heuristic, which
+ // prevents excessive spilling in pathological cases.
+ bool ReverseLocal = TRI->reverseLocalAssignment();
+ bool ForceGlobal = !ReverseLocal &&
+ (Size / SlotIndex::InstrDist) > (2 * MRI->getRegClass(Reg)->getNumRegs());
+
+ if (ExtraRegInfo[Reg].Stage == RS_Assign && !ForceGlobal && !LI->empty() &&
LIS->intervalIsInOneMBB(*LI)) {
// Allocate original local ranges in linear instruction order. Since they
// are singly defined, this produces optimal coloring in the absence of
// global interference and other constraints.
- if (!TRI->reverseLocalAssignment())
+ if (!ReverseLocal)
Prio = LI->beginIndex().getInstrDistance(Indexes->getLastIndex());
else {
// Allocating bottom up may allow many short LRGs to be assigned first
OpenPOWER on IntegriCloud