summaryrefslogtreecommitdiffstats
path: root/test/483-dce-block
diff options
context:
space:
mode:
authorNicolas Geoffray <ngeoffray@google.com>2015-04-28 00:52:43 +0100
committerNicolas Geoffray <ngeoffray@google.com>2015-05-01 10:12:56 +0100
commit6db49a74e8402d3b6c66536ea7ec988144c05d24 (patch)
tree5b7d56d16986eafc7f96c7604c63e5c636753989 /test/483-dce-block
parentaf5b02011232741496313e7654e8923cf64b1eb4 (diff)
downloadart-6db49a74e8402d3b6c66536ea7ec988144c05d24.zip
art-6db49a74e8402d3b6c66536ea7ec988144c05d24.tar.gz
art-6db49a74e8402d3b6c66536ea7ec988144c05d24.tar.bz2
Update the remaining input index of phis after deleting an input.
bug:20715803 bug:20690906 (cherry picked from commit 5d7b7f81ed5455893f984752c00571ef27cc97c5) Change-Id: Ie55739601b8d6fedc830d6e19d8a053392047d34
Diffstat (limited to 'test/483-dce-block')
-rw-r--r--test/483-dce-block/expected.txt1
-rw-r--r--test/483-dce-block/info.txt2
-rw-r--r--test/483-dce-block/src/Main.java58
3 files changed, 61 insertions, 0 deletions
diff --git a/test/483-dce-block/expected.txt b/test/483-dce-block/expected.txt
new file mode 100644
index 0000000..ef48625
--- /dev/null
+++ b/test/483-dce-block/expected.txt
@@ -0,0 +1 @@
+class Main
diff --git a/test/483-dce-block/info.txt b/test/483-dce-block/info.txt
new file mode 100644
index 0000000..3db88ab
--- /dev/null
+++ b/test/483-dce-block/info.txt
@@ -0,0 +1,2 @@
+Regression test for optimizing that used to crash
+compiling the `foo` method.
diff --git a/test/483-dce-block/src/Main.java b/test/483-dce-block/src/Main.java
new file mode 100644
index 0000000..2f66a74
--- /dev/null
+++ b/test/483-dce-block/src/Main.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2015 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.
+ */
+
+public class Main {
+ public static void foo(Object o, int a) {
+ Object result = null;
+ if (o instanceof Main) {
+ // The compiler optimizes the type of `o` by introducing
+ // a `HBoundType` in this block.
+ while (a != 3) {
+ if (a == 2) {
+ a++;
+ result = o;
+ continue;
+ } else if (willInline()) {
+ // This block will be detected as dead after inlining.
+ result = new Object();
+ continue;
+ }
+ result = new Object();
+ }
+ // The compiler produces a phi at the back edge for `result`.
+ // Before dead block elimination, the phi has three inputs:
+ // result = (new Object(), new Object(), HBoundType)
+ //
+ // After dead block elimination, the phi has now two inputs:
+ // result = (new Object(), HBoundType)
+ //
+ // Our internal data structure for linking users and inputs expect
+ // the input index stored in that data structure to be the index
+ // in the inputs array. So the index before dead block elimination
+ // of the `HBoundType` would be 2. Dead block elimination must update
+ // that index to be 1.
+ }
+ System.out.println(result.getClass());
+ }
+
+ public static boolean willInline() {
+ return false;
+ }
+
+ public static void main(String[] args) {
+ foo(new Main(), 2);
+ }
+}