Ensure ClearLoopInformation doesn't require particular ordering
The ClearLoopInformation call used to use the RPO list to find
blocks which potentially had loop-information. This meant that if one
was also clearing the dominance information (which is quite common)
one needed to be sure to call ClearLoopInformation before calling
ClearDominanceInformation or else loop information will not be fully
cleared. This could cause quite perplexing errors if dominance
information is recomputed later (also quite common). This error is in
fact present in several tests (none of which use loops which is how it
got missed).
Fix this issue by just looping over all blocks. Also add a new
GetActiveBlocks function which does the filtering of null blocks
automatically. In many cases (such as these) we use RPO purely because
it doesn't require filtering. This should be able to replace these
uses.
Test: ./test.py --host
Change-Id: I60c7defc409111471064e9bf02b7ae3a0eb10584
diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h
index 9fa21d5..d15e40a 100644
--- a/compiler/optimizing/nodes.h
+++ b/compiler/optimizing/nodes.h
@@ -430,6 +430,13 @@
const ArenaVector<HBasicBlock*>& GetBlocks() const { return blocks_; }
+ // An iterator to only blocks that are still actually in the graph (when
+ // blocks are removed they are replaced with 'nullptr' in GetBlocks to
+ // simplify block-id assignment and avoid memmoves in the block-list).
+ IterationRange<FilterNull<ArenaVector<HBasicBlock*>::const_iterator>> GetActiveBlocks() const {
+ return FilterOutNull(MakeIterationRange(GetBlocks()));
+ }
+
bool IsInSsaForm() const { return in_ssa_form_; }
void SetInSsaForm() { in_ssa_form_ = true; }