blob: 97a5424aa560c51eef3bef9b9aa710a4a7b4922b [file] [log] [blame]
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +00001//===-- SpillPlacement.cpp - Optimal Spill Code Placement -----------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the spill code placement analysis.
11//
12// Each edge bundle corresponds to a node in a Hopfield network. Constraints on
13// basic blocks are weighted by the block frequency and added to become the node
14// bias.
15//
16// Transparent basic blocks have the variable live through, but don't care if it
17// is spilled or in a register. These blocks become connections in the Hopfield
18// network, again weighted by block frequency.
19//
20// The Hopfield network minimizes (possibly locally) its energy function:
21//
22// E = -sum_n V_n * ( B_n + sum_{n, m linked by b} V_m * F_b )
23//
24// The energy function represents the expected spill code execution frequency,
25// or the cost of spilling. This is a Lyapunov function which never increases
26// when a node is updated. It is guaranteed to converge to a local minimum.
27//
28//===----------------------------------------------------------------------===//
29
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +000030#include "SpillPlacement.h"
Jakub Staszakb6970262013-03-18 23:45:45 +000031#include "llvm/ADT/BitVector.h"
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +000032#include "llvm/CodeGen/EdgeBundles.h"
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +000033#include "llvm/CodeGen/MachineBasicBlock.h"
Benjamin Kramere2a1d892013-06-17 19:00:36 +000034#include "llvm/CodeGen/MachineBlockFrequencyInfo.h"
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +000035#include "llvm/CodeGen/MachineFunction.h"
36#include "llvm/CodeGen/MachineLoopInfo.h"
37#include "llvm/CodeGen/Passes.h"
38#include "llvm/Support/Debug.h"
39#include "llvm/Support/Format.h"
Chris Bieneman1a984902014-09-19 22:46:28 +000040#include "llvm/Support/ManagedStatic.h"
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +000041
42using namespace llvm;
43
Chandler Carruth1b9dde02014-04-22 02:02:50 +000044#define DEBUG_TYPE "spillplacement"
45
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +000046char SpillPlacement::ID = 0;
47INITIALIZE_PASS_BEGIN(SpillPlacement, "spill-code-placement",
48 "Spill Code Placement Analysis", true, true)
49INITIALIZE_PASS_DEPENDENCY(EdgeBundles)
50INITIALIZE_PASS_DEPENDENCY(MachineLoopInfo)
51INITIALIZE_PASS_END(SpillPlacement, "spill-code-placement",
52 "Spill Code Placement Analysis", true, true)
53
54char &llvm::SpillPlacementID = SpillPlacement::ID;
55
56void SpillPlacement::getAnalysisUsage(AnalysisUsage &AU) const {
57 AU.setPreservesAll();
Benjamin Kramere2a1d892013-06-17 19:00:36 +000058 AU.addRequired<MachineBlockFrequencyInfo>();
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +000059 AU.addRequiredTransitive<EdgeBundles>();
60 AU.addRequiredTransitive<MachineLoopInfo>();
61 MachineFunctionPass::getAnalysisUsage(AU);
62}
63
64/// Node - Each edge bundle corresponds to a Hopfield node.
65///
66/// The node contains precomputed frequency data that only depends on the CFG,
67/// but Bias and Links are computed each time placeSpills is called.
68///
69/// The node Value is positive when the variable should be in a register. The
70/// value can change when linked nodes change, but convergence is very fast
71/// because all weights are positive.
72///
73struct SpillPlacement::Node {
Jakob Stoklund Olesenc5454ff2013-07-16 18:26:15 +000074 /// BiasN - Sum of blocks that prefer a spill.
75 BlockFrequency BiasN;
76 /// BiasP - Sum of blocks that prefer a register.
77 BlockFrequency BiasP;
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +000078
79 /// Value - Output value of this node computed from the Bias and links.
Jakob Stoklund Olesenc5454ff2013-07-16 18:26:15 +000080 /// This is always on of the values {-1, 0, 1}. A positive number means the
81 /// variable should go in a register through this bundle.
82 int Value;
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +000083
Jakob Stoklund Olesenc5454ff2013-07-16 18:26:15 +000084 typedef SmallVector<std::pair<BlockFrequency, unsigned>, 4> LinkVector;
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +000085
86 /// Links - (Weight, BundleNo) for all transparent blocks connecting to other
Jakob Stoklund Olesenc5454ff2013-07-16 18:26:15 +000087 /// bundles. The weights are all positive block frequencies.
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +000088 LinkVector Links;
89
Jakob Stoklund Olesenc5454ff2013-07-16 18:26:15 +000090 /// SumLinkWeights - Cached sum of the weights of all links + ThresHold.
91 BlockFrequency SumLinkWeights;
92
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +000093 /// preferReg - Return true when this node prefers to be in a register.
94 bool preferReg() const {
95 // Undecided nodes (Value==0) go on the stack.
96 return Value > 0;
97 }
98
99 /// mustSpill - Return True if this node is so biased that it must spill.
100 bool mustSpill() const {
Jakob Stoklund Olesenc5454ff2013-07-16 18:26:15 +0000101 // We must spill if Bias < -sum(weights) or the MustSpill flag was set.
102 // BiasN is saturated when MustSpill is set, make sure this still returns
103 // true when the RHS saturates. Note that SumLinkWeights includes Threshold.
104 return BiasN >= BiasP + SumLinkWeights;
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000105 }
106
107 /// clear - Reset per-query data, but preserve frequencies that only depend on
108 // the CFG.
Chandler Carruth7425c8c2014-10-02 22:23:14 +0000109 void clear(const BlockFrequency &Threshold) {
Jakob Stoklund Olesenc5454ff2013-07-16 18:26:15 +0000110 BiasN = BiasP = Value = 0;
Chandler Carruth7425c8c2014-10-02 22:23:14 +0000111 SumLinkWeights = Threshold;
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000112 Links.clear();
113 }
114
115 /// addLink - Add a link to bundle b with weight w.
Jakob Stoklund Olesenc5454ff2013-07-16 18:26:15 +0000116 void addLink(unsigned b, BlockFrequency w) {
117 // Update cached sum.
118 SumLinkWeights += w;
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000119
120 // There can be multiple links to the same bundle, add them up.
121 for (LinkVector::iterator I = Links.begin(), E = Links.end(); I != E; ++I)
122 if (I->second == b) {
123 I->first += w;
124 return;
125 }
126 // This must be the first link to b.
127 Links.push_back(std::make_pair(w, b));
128 }
129
Jakob Stoklund Olesenc5454ff2013-07-16 18:26:15 +0000130 /// addBias - Bias this node.
131 void addBias(BlockFrequency freq, BorderConstraint direction) {
132 switch (direction) {
133 default:
134 break;
135 case PrefReg:
136 BiasP += freq;
137 break;
138 case PrefSpill:
139 BiasN += freq;
140 break;
141 case MustSpill:
142 BiasN = BlockFrequency::getMaxFrequency();
143 break;
144 }
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000145 }
146
147 /// update - Recompute Value from Bias and Links. Return true when node
148 /// preference changes.
Chandler Carruth7425c8c2014-10-02 22:23:14 +0000149 bool update(const Node nodes[], const BlockFrequency &Threshold) {
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000150 // Compute the weighted sum of inputs.
Jakob Stoklund Olesenc5454ff2013-07-16 18:26:15 +0000151 BlockFrequency SumN = BiasN;
152 BlockFrequency SumP = BiasP;
153 for (LinkVector::iterator I = Links.begin(), E = Links.end(); I != E; ++I) {
154 if (nodes[I->second].Value == -1)
155 SumN += I->first;
156 else if (nodes[I->second].Value == 1)
157 SumP += I->first;
158 }
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000159
Jakob Stoklund Olesenc5454ff2013-07-16 18:26:15 +0000160 // Each weighted sum is going to be less than the total frequency of the
161 // bundle. Ideally, we should simply set Value = sign(SumP - SumN), but we
162 // will add a dead zone around 0 for two reasons:
163 //
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000164 // 1. It avoids arbitrary bias when all links are 0 as is possible during
165 // initial iterations.
166 // 2. It helps tame rounding errors when the links nominally sum to 0.
Jakob Stoklund Olesenc5454ff2013-07-16 18:26:15 +0000167 //
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000168 bool Before = preferReg();
Chandler Carruth7425c8c2014-10-02 22:23:14 +0000169 if (SumN >= SumP + Threshold)
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000170 Value = -1;
Chandler Carruth7425c8c2014-10-02 22:23:14 +0000171 else if (SumP >= SumN + Threshold)
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000172 Value = 1;
173 else
174 Value = 0;
175 return Before != preferReg();
176 }
177};
178
179bool SpillPlacement::runOnMachineFunction(MachineFunction &mf) {
180 MF = &mf;
181 bundles = &getAnalysis<EdgeBundles>();
182 loops = &getAnalysis<MachineLoopInfo>();
183
184 assert(!nodes && "Leaking node array");
185 nodes = new Node[bundles->getNumBundles()];
186
187 // Compute total ingoing and outgoing block frequencies for all bundles.
Jakob Stoklund Olesenc5454ff2013-07-16 18:26:15 +0000188 BlockFrequencies.resize(mf.getNumBlockIDs());
Michael Gottesman092647b2013-12-14 00:25:47 +0000189 MBFI = &getAnalysis<MachineBlockFrequencyInfo>();
Duncan P. N. Exon Smitha5df8132014-04-08 19:18:56 +0000190 setThreshold(MBFI->getEntryFreq());
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000191 for (MachineFunction::iterator I = mf.begin(), E = mf.end(); I != E; ++I) {
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000192 unsigned Num = I->getNumber();
Michael Gottesman092647b2013-12-14 00:25:47 +0000193 BlockFrequencies[Num] = MBFI->getBlockFreq(I);
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000194 }
195
196 // We never change the function.
197 return false;
198}
199
200void SpillPlacement::releaseMemory() {
201 delete[] nodes;
Craig Topperc0196b12014-04-14 00:51:57 +0000202 nodes = nullptr;
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000203}
204
205/// activate - mark node n as active if it wasn't already.
206void SpillPlacement::activate(unsigned n) {
207 if (ActiveNodes->test(n))
208 return;
209 ActiveNodes->set(n);
Chandler Carruth7425c8c2014-10-02 22:23:14 +0000210 nodes[n].clear(Threshold);
Jakob Stoklund Olesen29268b52012-05-21 03:11:23 +0000211
212 // Very large bundles usually come from big switches, indirect branches,
213 // landing pads, or loops with many 'continue' statements. It is difficult to
214 // allocate registers when so many different blocks are involved.
215 //
Jakob Stoklund Olesenc5454ff2013-07-16 18:26:15 +0000216 // Give a small negative bias to large bundles such that a substantial
217 // fraction of the connected blocks need to be interested before we consider
218 // expanding the region through the bundle. This helps compile time by
219 // limiting the number of blocks visited and the number of links in the
220 // Hopfield network.
221 if (bundles->getBlocks(n).size() > 100) {
222 nodes[n].BiasP = 0;
Michael Gottesman5e985ee2013-12-14 02:37:38 +0000223 nodes[n].BiasN = (MBFI->getEntryFreq() / 16);
Jakob Stoklund Olesenc5454ff2013-07-16 18:26:15 +0000224 }
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000225}
226
Chandler Carruth7425c8c2014-10-02 22:23:14 +0000227/// \brief Set the threshold for a given entry frequency.
228///
229/// Set the threshold relative to \c Entry. Since the threshold is used as a
230/// bound on the open interval (-Threshold;Threshold), 1 is the minimum
231/// threshold.
232void SpillPlacement::setThreshold(const BlockFrequency &Entry) {
233 // Apparently 2 is a good threshold when Entry==2^14, but we need to scale
234 // it. Divide by 2^13, rounding as appropriate.
235 uint64_t Freq = Entry.getFrequency();
236 uint64_t Scaled = (Freq >> 13) + bool(Freq & (1 << 12));
237 Threshold = std::max(UINT64_C(1), Scaled);
238}
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000239
Jakob Stoklund Olesen36b5d8a2011-04-06 19:13:57 +0000240/// addConstraints - Compute node biases and weights from a set of constraints.
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000241/// Set a bit in NodeMask for each active node.
Jakob Stoklund Olesen36b5d8a2011-04-06 19:13:57 +0000242void SpillPlacement::addConstraints(ArrayRef<BlockConstraint> LiveBlocks) {
243 for (ArrayRef<BlockConstraint>::iterator I = LiveBlocks.begin(),
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000244 E = LiveBlocks.end(); I != E; ++I) {
Jakob Stoklund Olesenc5454ff2013-07-16 18:26:15 +0000245 BlockFrequency Freq = BlockFrequencies[I->Number];
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000246
247 // Live-in to block?
248 if (I->Entry != DontCare) {
249 unsigned ib = bundles->getBundle(I->Number, 0);
250 activate(ib);
Jakob Stoklund Olesenc5454ff2013-07-16 18:26:15 +0000251 nodes[ib].addBias(Freq, I->Entry);
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000252 }
253
254 // Live-out from block?
255 if (I->Exit != DontCare) {
256 unsigned ob = bundles->getBundle(I->Number, 1);
257 activate(ob);
Jakob Stoklund Olesenc5454ff2013-07-16 18:26:15 +0000258 nodes[ob].addBias(Freq, I->Exit);
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000259 }
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000260 }
261}
262
Jakob Stoklund Olesen0ab5d0e2011-07-23 03:10:19 +0000263/// addPrefSpill - Same as addConstraints(PrefSpill)
Jakob Stoklund Olesen86954522011-08-03 23:09:38 +0000264void SpillPlacement::addPrefSpill(ArrayRef<unsigned> Blocks, bool Strong) {
Jakob Stoklund Olesen0ab5d0e2011-07-23 03:10:19 +0000265 for (ArrayRef<unsigned>::iterator I = Blocks.begin(), E = Blocks.end();
266 I != E; ++I) {
Jakob Stoklund Olesenc5454ff2013-07-16 18:26:15 +0000267 BlockFrequency Freq = BlockFrequencies[*I];
Jakob Stoklund Olesen86954522011-08-03 23:09:38 +0000268 if (Strong)
269 Freq += Freq;
Jakob Stoklund Olesen0ab5d0e2011-07-23 03:10:19 +0000270 unsigned ib = bundles->getBundle(*I, 0);
271 unsigned ob = bundles->getBundle(*I, 1);
272 activate(ib);
273 activate(ob);
Jakob Stoklund Olesenc5454ff2013-07-16 18:26:15 +0000274 nodes[ib].addBias(Freq, PrefSpill);
275 nodes[ob].addBias(Freq, PrefSpill);
Jakob Stoklund Olesen0ab5d0e2011-07-23 03:10:19 +0000276 }
277}
278
Jakob Stoklund Olesen6d2bbc12011-04-07 17:27:46 +0000279void SpillPlacement::addLinks(ArrayRef<unsigned> Links) {
280 for (ArrayRef<unsigned>::iterator I = Links.begin(), E = Links.end(); I != E;
281 ++I) {
282 unsigned Number = *I;
283 unsigned ib = bundles->getBundle(Number, 0);
284 unsigned ob = bundles->getBundle(Number, 1);
285
286 // Ignore self-loops.
287 if (ib == ob)
288 continue;
289 activate(ib);
290 activate(ob);
Jakob Stoklund Olesened47ed42011-04-09 02:59:09 +0000291 if (nodes[ib].Links.empty() && !nodes[ib].mustSpill())
292 Linked.push_back(ib);
293 if (nodes[ob].Links.empty() && !nodes[ob].mustSpill())
294 Linked.push_back(ob);
Jakob Stoklund Olesenc5454ff2013-07-16 18:26:15 +0000295 BlockFrequency Freq = BlockFrequencies[Number];
296 nodes[ib].addLink(ob, Freq);
297 nodes[ob].addLink(ib, Freq);
Jakob Stoklund Olesen6d2bbc12011-04-07 17:27:46 +0000298 }
299}
300
Jakob Stoklund Olesened47ed42011-04-09 02:59:09 +0000301bool SpillPlacement::scanActiveBundles() {
302 Linked.clear();
303 RecentPositive.clear();
304 for (int n = ActiveNodes->find_first(); n>=0; n = ActiveNodes->find_next(n)) {
Chandler Carruth7425c8c2014-10-02 22:23:14 +0000305 nodes[n].update(nodes, Threshold);
Jakob Stoklund Olesened47ed42011-04-09 02:59:09 +0000306 // A node that must spill, or a node without any links is not going to
307 // change its value ever again, so exclude it from iterations.
308 if (nodes[n].mustSpill())
309 continue;
310 if (!nodes[n].Links.empty())
311 Linked.push_back(n);
312 if (nodes[n].preferReg())
313 RecentPositive.push_back(n);
314 }
315 return !RecentPositive.empty();
316}
317
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000318/// iterate - Repeatedly update the Hopfield nodes until stability or the
319/// maximum number of iterations is reached.
320/// @param Linked - Numbers of linked nodes that need updating.
Jakob Stoklund Olesened47ed42011-04-09 02:59:09 +0000321void SpillPlacement::iterate() {
322 // First update the recently positive nodes. They have likely received new
323 // negative bias that will turn them off.
324 while (!RecentPositive.empty())
Chandler Carruth7425c8c2014-10-02 22:23:14 +0000325 nodes[RecentPositive.pop_back_val()].update(nodes, Threshold);
Jakob Stoklund Olesened47ed42011-04-09 02:59:09 +0000326
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000327 if (Linked.empty())
328 return;
329
330 // Run up to 10 iterations. The edge bundle numbering is closely related to
331 // basic block numbering, so there is a strong tendency towards chains of
332 // linked nodes with sequential numbers. By scanning the linked nodes
333 // backwards and forwards, we make it very likely that a single node can
334 // affect the entire network in a single iteration. That means very fast
335 // convergence, usually in a single iteration.
336 for (unsigned iteration = 0; iteration != 10; ++iteration) {
Manman Ren709c9512014-02-28 23:05:31 +0000337 // Scan backwards, skipping the last node when iteration is not zero. When
338 // iteration is not zero, the last node was just updated.
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000339 bool Changed = false;
340 for (SmallVectorImpl<unsigned>::const_reverse_iterator I =
Benjamin Kramerb6d0bd42014-03-02 12:27:27 +0000341 iteration == 0 ? Linked.rbegin() : std::next(Linked.rbegin()),
Manman Ren709c9512014-02-28 23:05:31 +0000342 E = Linked.rend(); I != E; ++I) {
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000343 unsigned n = *I;
Chandler Carruth7425c8c2014-10-02 22:23:14 +0000344 if (nodes[n].update(nodes, Threshold)) {
Jakob Stoklund Olesened47ed42011-04-09 02:59:09 +0000345 Changed = true;
346 if (nodes[n].preferReg())
347 RecentPositive.push_back(n);
348 }
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000349 }
Jakob Stoklund Olesened47ed42011-04-09 02:59:09 +0000350 if (!Changed || !RecentPositive.empty())
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000351 return;
352
353 // Scan forwards, skipping the first node which was just updated.
354 Changed = false;
355 for (SmallVectorImpl<unsigned>::const_iterator I =
Benjamin Kramerb6d0bd42014-03-02 12:27:27 +0000356 std::next(Linked.begin()), E = Linked.end(); I != E; ++I) {
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000357 unsigned n = *I;
Chandler Carruth7425c8c2014-10-02 22:23:14 +0000358 if (nodes[n].update(nodes, Threshold)) {
Jakob Stoklund Olesened47ed42011-04-09 02:59:09 +0000359 Changed = true;
360 if (nodes[n].preferReg())
361 RecentPositive.push_back(n);
362 }
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000363 }
Jakob Stoklund Olesened47ed42011-04-09 02:59:09 +0000364 if (!Changed || !RecentPositive.empty())
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000365 return;
366 }
367}
368
Jakob Stoklund Olesen36b5d8a2011-04-06 19:13:57 +0000369void SpillPlacement::prepare(BitVector &RegBundles) {
Jakob Stoklund Olesened47ed42011-04-09 02:59:09 +0000370 Linked.clear();
371 RecentPositive.clear();
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000372 // Reuse RegBundles as our ActiveNodes vector.
373 ActiveNodes = &RegBundles;
374 ActiveNodes->clear();
375 ActiveNodes->resize(bundles->getNumBundles());
Jakob Stoklund Olesen36b5d8a2011-04-06 19:13:57 +0000376}
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000377
Jakob Stoklund Olesen36b5d8a2011-04-06 19:13:57 +0000378bool
379SpillPlacement::finish() {
380 assert(ActiveNodes && "Call prepare() first");
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000381
Jakob Stoklund Olesen36b5d8a2011-04-06 19:13:57 +0000382 // Write preferences back to ActiveNodes.
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000383 bool Perfect = true;
Jakob Stoklund Olesen36b5d8a2011-04-06 19:13:57 +0000384 for (int n = ActiveNodes->find_first(); n>=0; n = ActiveNodes->find_next(n))
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000385 if (!nodes[n].preferReg()) {
Jakob Stoklund Olesen36b5d8a2011-04-06 19:13:57 +0000386 ActiveNodes->reset(n);
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000387 Perfect = false;
388 }
Craig Topperc0196b12014-04-14 00:51:57 +0000389 ActiveNodes = nullptr;
Jakob Stoklund Olesen8e236ea2011-01-06 01:21:53 +0000390 return Perfect;
391}