ART: Disable vectorization for debuggable graphs.
SuspendCheck environment is incorrectly initialized with
a stale version of the loop induction variable (a pre-loop one)
for vectorized loops. The value can be retrieved from a
corresponding stack maps only in case of asynchronous
deoptimization in debuggable mode. Thus this workaround forbids
loop optimizations on debuggable graphs so the bug is never
triggered.
Test: test-art-target, test-art-host.
Bug: 138601207
Change-Id: Ica9f61f471c024146b7823214ef952e1db2a4663
diff --git a/compiler/optimizing/loop_optimization.cc b/compiler/optimizing/loop_optimization.cc
index 9914127..3e1c42c 100644
--- a/compiler/optimizing/loop_optimization.cc
+++ b/compiler/optimizing/loop_optimization.cc
@@ -763,6 +763,11 @@
}
// Vectorize loop, if possible and valid.
if (kEnableVectorization &&
+ // Disable vectorization for debuggable graphs: this is a workaround for the bug
+ // in 'GenerateNewLoop' which caused the SuspendCheck environment to be invalid.
+ // TODO: b/138601207, investigate other possible cases with wrong environment values and
+ // possibly switch back vectorization on for debuggable graphs.
+ !graph_->IsDebuggable() &&
TrySetSimpleLoopHeader(header, &main_phi) &&
ShouldVectorize(node, body, trip_count) &&
TryAssignLastValue(node->loop_info, main_phi, preheader, /*collect_loop_uses*/ true)) {