summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2011-04-06 21:32:41 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2011-04-06 21:32:41 +0000
commit8ce2f436940daaecad399b46f1eea1f2d4dec624 (patch)
tree1f8327887bae6908070448df8c53ab5962eb2ec8
parent81439a83f4b8034cbda395a87c681ca8c56d1c78 (diff)
downloadbcm5719-llvm-8ce2f436940daaecad399b46f1eea1f2d4dec624.tar.gz
bcm5719-llvm-8ce2f436940daaecad399b46f1eea1f2d4dec624.zip
Also account for the spill code that would be inserted in live-through blocks with interference.
llvm-svn: 129030
-rw-r--r--llvm/lib/CodeGen/RegAllocGreedy.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/RegAllocGreedy.cpp b/llvm/lib/CodeGen/RegAllocGreedy.cpp
index 66ef62b1e9d..7564c1da89a 100644
--- a/llvm/lib/CodeGen/RegAllocGreedy.cpp
+++ b/llvm/lib/CodeGen/RegAllocGreedy.cpp
@@ -170,7 +170,7 @@ private:
void LRE_DidCloneVirtReg(unsigned, unsigned);
bool addSplitConstraints(unsigned, float&);
- float calcGlobalSplitCost(const BitVector&);
+ float calcGlobalSplitCost(unsigned, const BitVector&);
void splitAroundRegion(LiveInterval&, unsigned, const BitVector&,
SmallVectorImpl<LiveInterval*>&);
void calcGapWeights(unsigned, SmallVectorImpl<float>&);
@@ -520,7 +520,8 @@ bool RAGreedy::addSplitConstraints(unsigned PhysReg, float &Cost) {
/// pattern in LiveBundles. This cost should be added to the local cost of the
/// interference pattern in SplitConstraints.
///
-float RAGreedy::calcGlobalSplitCost(const BitVector &LiveBundles) {
+float RAGreedy::calcGlobalSplitCost(unsigned PhysReg,
+ const BitVector &LiveBundles) {
float GlobalCost = 0;
ArrayRef<SplitAnalysis::BlockInfo> UseBlocks = SA->getUseBlocks();
for (unsigned i = 0; i != UseBlocks.size(); ++i) {
@@ -538,14 +539,24 @@ float RAGreedy::calcGlobalSplitCost(const BitVector &LiveBundles) {
GlobalCost += Ins * SpillPlacer->getBlockFrequency(BC.Number);
}
+ InterferenceCache::Cursor Intf(IntfCache, PhysReg);
ArrayRef<unsigned> ThroughBlocks = SA->getThroughBlocks();
SplitConstraints.resize(UseBlocks.size() + ThroughBlocks.size());
for (unsigned i = 0; i != ThroughBlocks.size(); ++i) {
unsigned Number = ThroughBlocks[i];
bool RegIn = LiveBundles[Bundles->getBundle(Number, 0)];
bool RegOut = LiveBundles[Bundles->getBundle(Number, 1)];
- if (RegIn != RegOut)
- GlobalCost += SpillPlacer->getBlockFrequency(Number);
+ if (!RegIn && !RegOut)
+ continue;
+ if (RegIn && RegOut) {
+ // We need double spill code if this block has interference.
+ Intf.moveToBlock(Number);
+ if (Intf.hasInterference())
+ GlobalCost += 2*SpillPlacer->getBlockFrequency(Number);
+ continue;
+ }
+ // live-in / stack-out or stack-in live-out.
+ GlobalCost += SpillPlacer->getBlockFrequency(Number);
}
return GlobalCost;
}
@@ -811,7 +822,7 @@ unsigned RAGreedy::tryRegionSplit(LiveInterval &VirtReg, AllocationOrder &Order,
continue;
}
- Cost += calcGlobalSplitCost(LiveBundles);
+ Cost += calcGlobalSplitCost(PhysReg, LiveBundles);
DEBUG({
dbgs() << ", total = " << Cost << " with bundles";
for (int i = LiveBundles.find_first(); i>=0; i = LiveBundles.find_next(i))
OpenPOWER on IntegriCloud