Extract SpillPlacement::addLinks for handling the special transparent blocks.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129079 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/RegAllocGreedy.cpp b/lib/CodeGen/RegAllocGreedy.cpp
index 7564c1d..889bca3 100644
--- a/lib/CodeGen/RegAllocGreedy.cpp
+++ b/lib/CodeGen/RegAllocGreedy.cpp
@@ -123,9 +123,13 @@
/// Cached per-block interference maps
InterferenceCache IntfCache;
- /// All basic blocks where the current register is live.
+ /// All basic blocks where the current register has uses.
SmallVector<SpillPlacement::BlockConstraint, 8> SplitConstraints;
+ /// All basic blocks where the current register is live-through and
+ /// interference free.
+ SmallVector<unsigned, 8> TransparentBlocks;
+
/// Global live range splitting candidate info.
struct GlobalSplitCandidate {
unsigned PhysReg;
@@ -475,6 +479,7 @@
const unsigned GroupSize = 8;
SpillPlacement::BlockConstraint BCS[GroupSize];
unsigned B = 0;
+ TransparentBlocks.clear();
ArrayRef<unsigned> ThroughBlocks = SA->getThroughBlocks();
for (unsigned i = 0; i != ThroughBlocks.size(); ++i) {
@@ -483,23 +488,23 @@
BCS[B].Number = Number;
Intf.moveToBlock(Number);
- if (Intf.hasInterference()) {
- // Interference for the live-in value.
- if (Intf.first() <= Indexes->getMBBStartIdx(Number))
- BCS[B].Entry = SpillPlacement::MustSpill;
- else
- BCS[B].Entry = SpillPlacement::PrefSpill;
-
- // Interference for the live-out value.
- if (Intf.last() >= SA->getLastSplitPoint(Number))
- BCS[B].Exit = SpillPlacement::MustSpill;
- else
- BCS[B].Exit = SpillPlacement::PrefSpill;
- } else {
- // No interference, transparent block.
- BCS[B].Entry = BCS[B].Exit = SpillPlacement::DontCare;
+ if (!Intf.hasInterference()) {
+ TransparentBlocks.push_back(Number);
+ continue;
}
+ // Interference for the live-in value.
+ if (Intf.first() <= Indexes->getMBBStartIdx(Number))
+ BCS[B].Entry = SpillPlacement::MustSpill;
+ else
+ BCS[B].Entry = SpillPlacement::PrefSpill;
+
+ // Interference for the live-out value.
+ if (Intf.last() >= SA->getLastSplitPoint(Number))
+ BCS[B].Exit = SpillPlacement::MustSpill;
+ else
+ BCS[B].Exit = SpillPlacement::PrefSpill;
+
if (++B == GroupSize) {
ArrayRef<SpillPlacement::BlockConstraint> Array(BCS, B);
SpillPlacer->addConstraints(Array);
@@ -512,7 +517,12 @@
ArrayRef<SpillPlacement::BlockConstraint> Array(BCS, B);
SpillPlacer->addConstraints(Array);
- return SpillPlacer->getPositiveNodes() != 0;
+ if (SpillPlacer->getPositiveNodes() == 0)
+ return false;
+
+ // There is still some positive bias. Add all the links.
+ SpillPlacer->addLinks(TransparentBlocks);
+ return true;
}