summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Nicolas Geoffray <ngeoffray@google.com> 2021-11-16 15:12:04 +0000
committer Nicolas Geoffray <ngeoffray@google.com> 2021-11-17 13:52:10 +0000
commit3cb3670d162285c6e4304f1f9f85f7c3ff78150d (patch)
tree74e63fa4f17768bcd8bd4d793f414b50414503aa
parenta3fdf25f7d2800c7196422559ee1ea09cb74cc18 (diff)
Run LSE with LoadStoreAnalysisType::kBasic analysis.
Otherwise, the code assumes partial LSE gets run, which isn't the case as it's currently disabled. Test: 834-lse Bug: 205813546 Bug: 205676807 Merged-In: Ief5cba2964d60522e747395b60f90b862fcfe560 (cherry picked from commit 2498d855f80171d825ce1b98428cb05c8a504f84) Change-Id: I334e1be1f1270fcb25a32e62c2900970d11bfcde
-rw-r--r--compiler/optimizing/load_store_elimination.cc2
-rw-r--r--compiler/optimizing/load_store_elimination_test.cc6
-rw-r--r--test/530-checker-lse/src/Main.java2
-rw-r--r--test/834-lse/expected-stderr.txt0
-rw-r--r--test/834-lse/expected-stdout.txt0
-rw-r--r--test/834-lse/info.txt2
-rw-r--r--test/834-lse/src/Main.java40
7 files changed, 49 insertions, 3 deletions
diff --git a/compiler/optimizing/load_store_elimination.cc b/compiler/optimizing/load_store_elimination.cc
index 722cc83872..b7670329e6 100644
--- a/compiler/optimizing/load_store_elimination.cc
+++ b/compiler/optimizing/load_store_elimination.cc
@@ -3889,7 +3889,7 @@ bool LoadStoreElimination::Run(bool enable_partial_lse) {
stats_,
&allocator,
enable_partial_lse ? LoadStoreAnalysisType::kFull
- : LoadStoreAnalysisType::kNoPredicatedInstructions);
+ : LoadStoreAnalysisType::kBasic);
lsa.Run();
const HeapLocationCollector& heap_location_collector = lsa.GetHeapLocationCollector();
if (heap_location_collector.GetNumberOfHeapLocations() == 0) {
diff --git a/compiler/optimizing/load_store_elimination_test.cc b/compiler/optimizing/load_store_elimination_test.cc
index 812a32aeec..01a00d0c4a 100644
--- a/compiler/optimizing/load_store_elimination_test.cc
+++ b/compiler/optimizing/load_store_elimination_test.cc
@@ -4532,7 +4532,8 @@ TEST_F(LoadStoreEliminationTest, PartialLoadPreserved3) {
// // DO NOT ELIMINATE
// return obj.field;
// EXIT
-TEST_F(LoadStoreEliminationTest, PartialLoadPreserved4) {
+// Disabled due to b/205813546.
+TEST_F(LoadStoreEliminationTest, DISABLED_PartialLoadPreserved4) {
ScopedObjectAccess soa(Thread::Current());
VariableSizedHandleScope vshs(soa.Self());
CreateGraph(&vshs);
@@ -4724,7 +4725,8 @@ TEST_F(LoadStoreEliminationTest, PartialLoadPreserved5) {
// EXIT
// ELIMINATE
// return obj.field
-TEST_F(LoadStoreEliminationTest, PartialLoadPreserved6) {
+// Disabled due to b/205813546.
+TEST_F(LoadStoreEliminationTest, DISABLED_PartialLoadPreserved6) {
CreateGraph();
AdjacencyListGraph blks(SetupFromAdjacencyList("entry",
"exit",
diff --git a/test/530-checker-lse/src/Main.java b/test/530-checker-lse/src/Main.java
index a707a8ae5c..3d97049f2c 100644
--- a/test/530-checker-lse/src/Main.java
+++ b/test/530-checker-lse/src/Main.java
@@ -3942,6 +3942,8 @@ public class Main {
/// CHECK-START: int Main.$noinline$testPartialEscape1(TestClass, boolean) load_store_elimination (after)
/// CHECK: InstanceFieldSet
//
+ // TODO: We should be able to remove this setter by realizing `i` only escapes in a branch.
+ /// CHECK: InstanceFieldSet
/// CHECK-NOT: InstanceFieldSet
//
/// CHECK-START: int Main.$noinline$testPartialEscape1(TestClass, boolean) load_store_elimination (after)
diff --git a/test/834-lse/expected-stderr.txt b/test/834-lse/expected-stderr.txt
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/test/834-lse/expected-stderr.txt
diff --git a/test/834-lse/expected-stdout.txt b/test/834-lse/expected-stdout.txt
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/test/834-lse/expected-stdout.txt
diff --git a/test/834-lse/info.txt b/test/834-lse/info.txt
new file mode 100644
index 0000000000..8229be934f
--- /dev/null
+++ b/test/834-lse/info.txt
@@ -0,0 +1,2 @@
+Regression test for the load-store-elimination pass, which used to remove stores
+too agressively.
diff --git a/test/834-lse/src/Main.java b/test/834-lse/src/Main.java
new file mode 100644
index 0000000000..65139696bc
--- /dev/null
+++ b/test/834-lse/src/Main.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2021 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 Main {
+ int myField;
+ static boolean test;
+
+ static void $noinline$assertEquals(int expected, int actual) {
+ if (expected != actual) {
+ throw new Error("Expected " + expected + ", got " + actual);
+ }
+ }
+
+ static void $noinline$empty() {}
+ static void $noinline$escape(Object m) {}
+
+ public static void main(String[] args) {
+ Main m = new Main();
+ if (test) {
+ $noinline$escape(m);
+ } else {
+ m.myField = 42;
+ }
+ $noinline$empty();
+ $noinline$assertEquals(42, m.myField);
+ }
+}