summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorNicolas Geoffray <ngeoffray@google.com>2015-03-11 18:13:21 +0000
committerNicolas Geoffray <ngeoffray@google.com>2015-03-11 18:13:21 +0000
commitb59dba05697b4ac6c86cb4f45c9222c9c6ad852b (patch)
tree83cd372b86498c7a78d08be11d6e9f73d7338665 /test
parent356286f989941ac495417195e4129aaceaf36a83 (diff)
downloadart-b59dba05697b4ac6c86cb4f45c9222c9c6ad852b.zip
art-b59dba05697b4ac6c86cb4f45c9222c9c6ad852b.tar.gz
art-b59dba05697b4ac6c86cb4f45c9222c9c6ad852b.tar.bz2
Fix a bug in the SSA builder.
The build would leave behind phis with incompatible input types (for example float and int). We need another dead phi run after the type propagation to ensure all such phis are dead. Change-Id: I6ef1da725c7d4a1ebaf6b52dd7eb0c7bacd261b2
Diffstat (limited to 'test')
-rw-r--r--test/459-dead-phi/expected.txt1
-rw-r--r--test/459-dead-phi/info.txt1
-rw-r--r--test/459-dead-phi/smali/EquivalentPhi.smali41
-rw-r--r--test/459-dead-phi/src/Main.java29
4 files changed, 72 insertions, 0 deletions
diff --git a/test/459-dead-phi/expected.txt b/test/459-dead-phi/expected.txt
new file mode 100644
index 0000000..ba66466
--- /dev/null
+++ b/test/459-dead-phi/expected.txt
@@ -0,0 +1 @@
+0.0
diff --git a/test/459-dead-phi/info.txt b/test/459-dead-phi/info.txt
new file mode 100644
index 0000000..3f82ecb
--- /dev/null
+++ b/test/459-dead-phi/info.txt
@@ -0,0 +1 @@
+Regression test for optimizing when it is building the SSA form.
diff --git a/test/459-dead-phi/smali/EquivalentPhi.smali b/test/459-dead-phi/smali/EquivalentPhi.smali
new file mode 100644
index 0000000..4fa88a9
--- /dev/null
+++ b/test/459-dead-phi/smali/EquivalentPhi.smali
@@ -0,0 +1,41 @@
+# 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.
+
+.class public LEquivalentPhi;
+
+.super Ljava/lang/Object;
+
+.method public static equivalentPhi([F)F
+ .registers 5
+ const/4 v0, 0x0
+ # aget is initally expected to be an int, but will
+ # rightly become a float after type propagation.
+ aget v1, p0, v0
+ move v2, v1
+ if-eq v0, v0, :else
+ move v2, v0
+ :else
+ # v2 will be a phi with (int, int) as input
+ move v3, v2
+ if-eq v0, v0, :else2
+ move v3, v0
+ # v3 will be a phi with (int, int) as input.
+ : else2
+ # This instruction will lead to creating a phi equivalent
+ # for v3 with float type, which in turn will lead to creating
+ # a phi equivalent for v2 of type float. We used to forget to
+ # delete the old phi, which ends up having incompatible input
+ # types.
+ return v3
+.end method
diff --git a/test/459-dead-phi/src/Main.java b/test/459-dead-phi/src/Main.java
new file mode 100644
index 0000000..0ecc0bd
--- /dev/null
+++ b/test/459-dead-phi/src/Main.java
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+
+import java.lang.reflect.Method;
+
+public class Main {
+
+ // Workaround for b/18051191.
+ class InnerClass {}
+
+ public static void main(String[] args) throws Exception {
+ Class<?> c = Class.forName("EquivalentPhi");
+ Method m = c.getMethod("equivalentPhi", float[].class);
+ System.out.println(m.invoke(null, new float[] { 0.0f }));
+ }
+}