[llvm-commits] [llvm] r129021 - in /llvm/trunk/lib/CodeGen: RegAllocGreedy.cpp SpillPlacement.cpp SpillPlacement.h
Jakob Stoklund Olesen
stoklund at 2pi.dk
Wed Apr 6 12:14:00 PDT 2011
Author: stoklund
Date: Wed Apr 6 14:14:00 2011
New Revision: 129021
URL: http://llvm.org/viewvc/llvm-project?rev=129021&view=rev
Log:
Keep track of the number of positively biased nodes when adding constraints.
If there are no positive nodes, the algorithm can be aborted early.
Modified:
llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp
llvm/trunk/lib/CodeGen/SpillPlacement.cpp
llvm/trunk/lib/CodeGen/SpillPlacement.h
Modified: llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp?rev=129021&r1=129020&r2=129021&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp (original)
+++ llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp Wed Apr 6 14:14:00 2011
@@ -772,6 +772,7 @@
SpillPlacer->prepare(LiveBundles);
SpillPlacer->addConstraints(SplitConstraints);
+ DEBUG(dbgs() << ", " << SpillPlacer->getPositiveNodes() << " biased nodes");
SpillPlacer->finish();
// No live bundles, defer to splitSingleBlocks().
Modified: llvm/trunk/lib/CodeGen/SpillPlacement.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SpillPlacement.cpp?rev=129021&r1=129020&r2=129021&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SpillPlacement.cpp (original)
+++ llvm/trunk/lib/CodeGen/SpillPlacement.cpp Wed Apr 6 14:14:00 2011
@@ -134,10 +134,14 @@
}
/// addBias - Bias this node from an ingoing[0] or outgoing[1] link.
- void addBias(float w, bool out) {
+ /// Return the change to the total number of positive biases.
+ int addBias(float w, bool out) {
// Normalize w relative to all connected blocks from that direction.
w /= Frequency[out];
+ int Before = Bias > 0;
Bias += w;
+ int After = Bias > 0;
+ return After - Before;
}
/// update - Recompute Value from Bias and Links. Return true when node
@@ -237,14 +241,14 @@
if (I->Entry != DontCare) {
unsigned ib = bundles->getBundle(I->Number, 0);
activate(ib);
- nodes[ib].addBias(Freq * Bias[I->Entry], 1);
+ PositiveNodes += nodes[ib].addBias(Freq * Bias[I->Entry], 1);
}
// Live-out from block?
if (I->Exit != DontCare) {
unsigned ob = bundles->getBundle(I->Number, 1);
activate(ob);
- nodes[ob].addBias(Freq * Bias[I->Exit], 0);
+ PositiveNodes += nodes[ob].addBias(Freq * Bias[I->Exit], 0);
}
}
}
@@ -292,6 +296,7 @@
ActiveNodes = &RegBundles;
ActiveNodes->clear();
ActiveNodes->resize(bundles->getNumBundles());
+ PositiveNodes = 0;
}
bool
Modified: llvm/trunk/lib/CodeGen/SpillPlacement.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SpillPlacement.h?rev=129021&r1=129020&r2=129021&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SpillPlacement.h (original)
+++ llvm/trunk/lib/CodeGen/SpillPlacement.h Wed Apr 6 14:14:00 2011
@@ -49,6 +49,9 @@
// caller.
BitVector *ActiveNodes;
+ // The number of active nodes with a positive bias.
+ unsigned PositiveNodes;
+
// Block frequencies are computed once. Indexed by block number.
SmallVector<float, 4> BlockFrequency;
@@ -91,6 +94,10 @@
/// out, but not live in.
void addConstraints(ArrayRef<BlockConstraint> LiveBlocks);
+ /// getPositiveNodes - Return the total number of graph nodes with a positive
+ /// bias after adding constraints.
+ unsigned getPositiveNodes() const { return PositiveNodes; }
+
/// finish - Compute the optimal spill code placement given the
/// constraints. No MustSpill constraints will be violated, and the smallest
/// possible number of PrefX constraints will be violated, weighted by
More information about the llvm-commits
mailing list