summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2011-08-03 23:09:38 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2011-08-03 23:09:38 +0000
commit869545203b60192f656220258c759d5d6dc73897 (patch)
treec94145d824c88daf1464d32776ce18a5bc846887 /llvm/lib/CodeGen
parent77eb5a0a3767604dc511e537b2b32ea74be70259 (diff)
downloadbcm5719-llvm-869545203b60192f656220258c759d5d6dc73897.tar.gz
bcm5719-llvm-869545203b60192f656220258c759d5d6dc73897.zip
Be more conservative when forming compact regions.
Apply twice the negative bias on transparent blocks when computing the compact regions. This excludes loop backedges from the region when only one of the loop blocks uses the register. Previously, we would include the backedge in the region if the loop preheader and the loop latch both used the register, but the loop header didn't. When both the header and latch blocks use the register, we still keep it live on the backedge. llvm-svn: 136832
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/RegAllocGreedy.cpp4
-rw-r--r--llvm/lib/CodeGen/SpillPlacement.cpp4
-rw-r--r--llvm/lib/CodeGen/SpillPlacement.h3
3 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/RegAllocGreedy.cpp b/llvm/lib/CodeGen/RegAllocGreedy.cpp
index 1cbd5a925f2..4c130d0026b 100644
--- a/llvm/lib/CodeGen/RegAllocGreedy.cpp
+++ b/llvm/lib/CodeGen/RegAllocGreedy.cpp
@@ -806,7 +806,9 @@ void RAGreedy::growRegion(GlobalSplitCandidate &Cand) {
if (Cand.PhysReg)
addThroughConstraints(Cand.Intf, NewBlocks);
else
- SpillPlacer->addPrefSpill(NewBlocks);
+ // Provide a strong negative bias on through blocks to prevent unwanted
+ // liveness on loop backedges.
+ SpillPlacer->addPrefSpill(NewBlocks, /* Strong= */ true);
AddedTo = ActiveBlocks.size();
// Perhaps iterating can enable more bundles?
diff --git a/llvm/lib/CodeGen/SpillPlacement.cpp b/llvm/lib/CodeGen/SpillPlacement.cpp
index 10a3c189624..6f33f5465ca 100644
--- a/llvm/lib/CodeGen/SpillPlacement.cpp
+++ b/llvm/lib/CodeGen/SpillPlacement.cpp
@@ -241,10 +241,12 @@ void SpillPlacement::addConstraints(ArrayRef<BlockConstraint> LiveBlocks) {
}
/// addPrefSpill - Same as addConstraints(PrefSpill)
-void SpillPlacement::addPrefSpill(ArrayRef<unsigned> Blocks) {
+void SpillPlacement::addPrefSpill(ArrayRef<unsigned> Blocks, bool Strong) {
for (ArrayRef<unsigned>::iterator I = Blocks.begin(), E = Blocks.end();
I != E; ++I) {
float Freq = getBlockFrequency(*I);
+ if (Strong)
+ Freq += Freq;
unsigned ib = bundles->getBundle(*I, 0);
unsigned ob = bundles->getBundle(*I, 1);
activate(ib);
diff --git a/llvm/lib/CodeGen/SpillPlacement.h b/llvm/lib/CodeGen/SpillPlacement.h
index 9d1d676c54a..fc412f817cd 100644
--- a/llvm/lib/CodeGen/SpillPlacement.h
+++ b/llvm/lib/CodeGen/SpillPlacement.h
@@ -107,7 +107,8 @@ public:
/// Entry = Exit = PrefSpill, and ChangesValue = false.
///
/// @param Blocks Array of block numbers that prefer to spill in and out.
- void addPrefSpill(ArrayRef<unsigned> Blocks);
+ /// @param Strong When true, double the negative bias for these blocks.
+ void addPrefSpill(ArrayRef<unsigned> Blocks, bool Strong);
/// addLinks - Add transparent blocks with the given numbers.
void addLinks(ArrayRef<unsigned> Links);
OpenPOWER on IntegriCloud