summaryrefslogtreecommitdiff
path: root/lib/CodeGen/SpillPlacement.cpp
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2011-04-06 19:13:57 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2011-04-06 19:13:57 +0000
commit9efa2a263ea470caacef1c85f6ca45e32bf516d3 (patch)
treea53dc8a880e331f92a28e9d4d63711136a746fba /lib/CodeGen/SpillPlacement.cpp
parent77b42e9654c6c226d29aeb0883955874ea881068 (diff)
downloadllvm-9efa2a263ea470caacef1c85f6ca45e32bf516d3.tar.gz
llvm-9efa2a263ea470caacef1c85f6ca45e32bf516d3.tar.bz2
llvm-9efa2a263ea470caacef1c85f6ca45e32bf516d3.tar.xz
Break the spill placement algorithm into three parts: prepare, addConstraints, and finish.
This will allow us to abort the algorithm early if it is determined to be futile. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129020 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SpillPlacement.cpp')
-rw-r--r--lib/CodeGen/SpillPlacement.cpp27
1 files changed, 13 insertions, 14 deletions
diff --git a/lib/CodeGen/SpillPlacement.cpp b/lib/CodeGen/SpillPlacement.cpp
index 57951ed806..d648d5a9e1 100644
--- a/lib/CodeGen/SpillPlacement.cpp
+++ b/lib/CodeGen/SpillPlacement.cpp
@@ -203,11 +203,10 @@ void SpillPlacement::activate(unsigned n) {
}
-/// prepareNodes - Compute node biases and weights from a set of constraints.
+/// addConstraints - Compute node biases and weights from a set of constraints.
/// Set a bit in NodeMask for each active node.
-void SpillPlacement::
-prepareNodes(const SmallVectorImpl<BlockConstraint> &LiveBlocks) {
- for (SmallVectorImpl<BlockConstraint>::const_iterator I = LiveBlocks.begin(),
+void SpillPlacement::addConstraints(ArrayRef<BlockConstraint> LiveBlocks) {
+ for (ArrayRef<BlockConstraint>::iterator I = LiveBlocks.begin(),
E = LiveBlocks.end(); I != E; ++I) {
float Freq = getBlockFrequency(I->Number);
@@ -288,21 +287,20 @@ void SpillPlacement::iterate(const SmallVectorImpl<unsigned> &Linked) {
}
}
-bool
-SpillPlacement::placeSpills(const SmallVectorImpl<BlockConstraint> &LiveBlocks,
- BitVector &RegBundles) {
+void SpillPlacement::prepare(BitVector &RegBundles) {
// Reuse RegBundles as our ActiveNodes vector.
ActiveNodes = &RegBundles;
ActiveNodes->clear();
ActiveNodes->resize(bundles->getNumBundles());
+}
- // Compute active nodes, links and biases.
- prepareNodes(LiveBlocks);
-
+bool
+SpillPlacement::finish() {
+ assert(ActiveNodes && "Call prepare() first");
// Update all active nodes, and find the ones that are actually linked to
// something so their value may change when iterating.
SmallVector<unsigned, 8> Linked;
- for (int n = RegBundles.find_first(); n>=0; n = RegBundles.find_next(n)) {
+ for (int n = ActiveNodes->find_first(); n>=0; n = ActiveNodes->find_next(n)) {
nodes[n].update(nodes);
// A node that must spill, or a node without any links is not going to
// change its value ever again, so exclude it from iterations.
@@ -313,12 +311,13 @@ SpillPlacement::placeSpills(const SmallVectorImpl<BlockConstraint> &LiveBlocks,
// Iterate the network to convergence.
iterate(Linked);
- // Write preferences back to RegBundles.
+ // Write preferences back to ActiveNodes.
bool Perfect = true;
- for (int n = RegBundles.find_first(); n>=0; n = RegBundles.find_next(n))
+ for (int n = ActiveNodes->find_first(); n>=0; n = ActiveNodes->find_next(n))
if (!nodes[n].preferReg()) {
- RegBundles.reset(n);
+ ActiveNodes->reset(n);
Perfect = false;
}
+ ActiveNodes = 0;
return Perfect;
}