summaryrefslogtreecommitdiff
path: root/compiler/optimizing/bounds_check_elimination.cc
diff options
context:
space:
mode:
author Aart Bik <ajcbik@google.com> 2016-02-29 13:56:44 -0800
committer Aart Bik <ajcbik@google.com> 2016-02-29 16:37:49 -0800
commitb6347b7a3dbf9f55cbd638c630e9d044d6d53ac6 (patch)
tree676d2a23b19d4302b13841726ee559763980b5f4 /compiler/optimizing/bounds_check_elimination.cc
parent9f03916ff79dca0d529a39c0202b67ac256cf9df (diff)
Fixed bug on incorrectly revisiting same block.
Rationale: Aart's fuzz tester found this particular bug, where revisiting a block (after dynamic bce) would cause static array length based bce to feed into itself and thus incorrectly remove a needed bounds check. bug=27376274 Change-Id: I9163f283af355d444b4cec707f194fe2b67c2572
Diffstat (limited to 'compiler/optimizing/bounds_check_elimination.cc')
-rw-r--r--compiler/optimizing/bounds_check_elimination.cc13
1 files changed, 5 insertions, 8 deletions
diff --git a/compiler/optimizing/bounds_check_elimination.cc b/compiler/optimizing/bounds_check_elimination.cc
index a7a1c0f2c4..288322e1c7 100644
--- a/compiler/optimizing/bounds_check_elimination.cc
+++ b/compiler/optimizing/bounds_check_elimination.cc
@@ -1711,21 +1711,18 @@ void BoundsCheckElimination::Run() {
// that value dominated by that instruction fits in that range. Range of that
// value can be narrowed further down in the dominator tree.
BCEVisitor visitor(graph_, side_effects_, induction_analysis_);
- HBasicBlock* last_visited_block = nullptr;
for (HReversePostOrderIterator it(*graph_); !it.Done(); it.Advance()) {
HBasicBlock* current = it.Current();
- if (current == last_visited_block) {
- // We may insert blocks into the reverse post order list when processing
- // a loop header. Don't process it again.
- DCHECK(current->IsLoopHeader());
- continue;
- }
if (visitor.IsAddedBlock(current)) {
// Skip added blocks. Their effects are already taken care of.
continue;
}
visitor.VisitBasicBlock(current);
- last_visited_block = current;
+ // Skip forward to the current block in case new basic blocks were inserted
+ // (which always appear earlier in reverse post order) to avoid visiting the
+ // same basic block twice.
+ for ( ; !it.Done() && it.Current() != current; it.Advance()) {
+ }
}
// Perform cleanup.