Fix broken gtests after SuspendCheck optimization
Fixes hardcoded graph dumps in pretty printer tests and an assumption
that non-zero branch offset in dex implies presence of HInstructions.
Change-Id: Iee273c06b7b36410b4621107bef2f3592ece2f5b
diff --git a/compiler/optimizing/builder.cc b/compiler/optimizing/builder.cc
index eed5614..c509606 100644
--- a/compiler/optimizing/builder.cc
+++ b/compiler/optimizing/builder.cc
@@ -1077,11 +1077,10 @@
if (target_offset <= 0) {
// DX generates back edges to the first encountered return. We can save
// time of later passes by not adding redundant suspend checks.
- if (target_offset != 0) {
- DCHECK(target->GetLastInstruction() != nullptr);
- if (target->GetLastInstruction()->IsReturn()) {
- return;
- }
+ HInstruction* last_in_target = target->GetLastInstruction();
+ if (last_in_target != nullptr &&
+ (last_in_target->IsReturn() || last_in_target->IsReturnVoid())) {
+ return;
}
// Add a suspend check to backward branches which may potentially loop. We