Fix dead-array after dead code elimination
Change-Id: Iab64df49bfc58c33b03423d29fccb8e9f2de1a45
diff --git a/src/main/java/com/android/tools/r8/ir/code/ArrayPut.java b/src/main/java/com/android/tools/r8/ir/code/ArrayPut.java
index 4e43590..13f8213 100644
--- a/src/main/java/com/android/tools/r8/ir/code/ArrayPut.java
+++ b/src/main/java/com/android/tools/r8/ir/code/ArrayPut.java
@@ -159,18 +159,24 @@
return true;
}
- // Check that all usages of the array are array stores.
- for (Instruction user : array.uniqueUsers()) {
- if (!user.isArrayPut() || user.asArrayPut().array() != array) {
- return true;
- }
- }
-
- if (array.numberOfPhiUsers() > 0) {
+ if (array.hasPhiUsers()) {
// The array could be used indirectly.
return true;
}
+ // Check that all usages of the array are array stores.
+ for (Instruction user : array.aliasedUsers()) {
+ if (user.isAssume()) {
+ if (user.outValue().hasPhiUsers()) {
+ return true;
+ }
+ continue;
+ }
+ if (!user.isArrayPut() || user.asArrayPut().array().getAliasedValue() != array) {
+ return true;
+ }
+ }
+
return false;
}