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
diff --git a/compiler/optimizing/pretty_printer_test.cc b/compiler/optimizing/pretty_printer_test.cc
index da6b294..a231a72 100644
--- a/compiler/optimizing/pretty_printer_test.cc
+++ b/compiler/optimizing/pretty_printer_test.cc
@@ -100,17 +100,16 @@
 TEST(PrettyPrinterTest, CFG3) {
   const char* expected =
     "BasicBlock 0, succ: 1\n"
-    "  5: SuspendCheck\n"
-    "  6: Goto 1\n"
+    "  4: SuspendCheck\n"
+    "  5: Goto 1\n"
     "BasicBlock 1, pred: 0, succ: 3\n"
     "  0: Goto 3\n"
     "BasicBlock 2, pred: 3, succ: 4\n"
     "  1: ReturnVoid\n"
     "BasicBlock 3, pred: 1, succ: 2\n"
-    "  2: SuspendCheck\n"
-    "  3: Goto 2\n"
+    "  2: Goto 2\n"
     "BasicBlock 4, pred: 2\n"
-    "  4: Exit\n";
+    "  3: Exit\n";
 
   const uint16_t data1[] = ZERO_REGISTER_CODE_ITEM(
     Instruction::GOTO | 0x200,
@@ -160,15 +159,14 @@
 TEST(PrettyPrinterTest, CFG5) {
   const char* expected =
     "BasicBlock 0, succ: 1\n"
-    "  4: SuspendCheck\n"
-    "  5: Goto 1\n"
+    "  3: SuspendCheck\n"
+    "  4: Goto 1\n"
     "BasicBlock 1, pred: 0, 2, succ: 3\n"
     "  0: ReturnVoid\n"
     "BasicBlock 2, succ: 1\n"
-    "  1: SuspendCheck\n"
-    "  2: Goto 1\n"
+    "  1: Goto 1\n"
     "BasicBlock 3, pred: 1\n"
-    "  3: Exit\n";
+    "  2: Exit\n";
 
   const uint16_t data[] = ZERO_REGISTER_CODE_ITEM(
     Instruction::RETURN_VOID,