Merge "ART: cleanup exit_block_ in graph if exit block is removed"
diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc
index 0e0b83e..77ded29 100644
--- a/compiler/optimizing/nodes.cc
+++ b/compiler/optimizing/nodes.cc
@@ -127,6 +127,9 @@
       // Remove the block from the list of blocks, so that further analyses
       // never see it.
       blocks_[i] = nullptr;
+      if (block->IsExitBlock()) {
+        SetExitBlock(nullptr);
+      }
     }
   }
 }
@@ -1870,7 +1873,7 @@
   DCHECK(block->GetPhis().IsEmpty());
 
   if (block->IsExitBlock()) {
-    exit_block_ = nullptr;
+    SetExitBlock(nullptr);
   }
 
   RemoveElement(reverse_post_order_, block);
diff --git a/test/579-inline-infinite/expected.txt b/test/579-inline-infinite/expected.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/579-inline-infinite/expected.txt
diff --git a/test/579-inline-infinite/info.txt b/test/579-inline-infinite/info.txt
new file mode 100644
index 0000000..6fb917c
--- /dev/null
+++ b/test/579-inline-infinite/info.txt
@@ -0,0 +1,2 @@
+Regression test for optimizing.
+Inlining of method with infinite loop cause a crash.
diff --git a/test/579-inline-infinite/src/Main.java b/test/579-inline-infinite/src/Main.java
new file mode 100644
index 0000000..f214ed4
--- /dev/null
+++ b/test/579-inline-infinite/src/Main.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+class Infinite implements Runnable {
+  public int field;
+
+  private final void $noinline$infinite() {
+    while(true) {
+      field++;
+    }
+  }
+
+  public void run() {
+    $noinline$infinite();
+  }
+}
+
+public class Main {
+  public static void main(String[] args) {
+    Thread thr = new Thread(new Infinite());
+    thr.setDaemon(true);
+    thr.start();
+    // This is a compiler test, so just finish.
+  }
+}