From bb6cda60e4418c0ab557ea4090e046bed8206763 Mon Sep 17 00:00:00 2001 From: Alex Light Date: Thu, 9 Jul 2020 13:24:56 -0700 Subject: Partial LSE analysis & store removal This is the first piece of partial LSE for art. This CL adds analysis tools needed to implement partial LSE. More immediately, it improves LSE so that it will remove stores that are provably non-observable based on the location they occur. For example: ``` Foo o = new Foo(); if (xyz) { check(foo); foo.x++; } else { foo.x = 12; } return foo.x; ``` The store of 12 can be removed because the only escape in this method is unreachable and was not executed by the point we reach the store. The main purpose of this CL is to add the analysis tools needed to implement partial Load-Store elimination. Namely it includes tracking of which blocks are escaping and the groups of blocks that we cannot remove allocations from. The actual impact of this change is incredibly minor, being triggered only once in a AOSP code. go/lem shows only minor effects to compile-time and no effect on the compiled code. See go/lem-allight-partial-lse-2 for numbers. Compile time shows an average of 1.4% regression (max regression is 7% with 0.2 noise). This CL adds a new 'reachability' concept to the HGraph. If this has been calculated it allows one to quickly query whether there is any execution path containing two blocks in a given order. This is used to define a notion of sections of graph from which the escape of some allocation is inevitable. Test: art_compiler_tests Test: treehugger Bug: 67037140 Change-Id: I0edc8d6b73f7dd329cb1ea7923080a0abe913ea6 --- compiler/optimizing/execution_subgraph_test.h | 38 +++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 compiler/optimizing/execution_subgraph_test.h (limited to 'compiler/optimizing/execution_subgraph_test.h') diff --git a/compiler/optimizing/execution_subgraph_test.h b/compiler/optimizing/execution_subgraph_test.h new file mode 100644 index 0000000000..13cb2bc7c5 --- /dev/null +++ b/compiler/optimizing/execution_subgraph_test.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2020 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. + */ + +#ifndef ART_COMPILER_OPTIMIZING_EXECUTION_SUBGRAPH_TEST_H_ +#define ART_COMPILER_OPTIMIZING_EXECUTION_SUBGRAPH_TEST_H_ + +#include "android-base/macros.h" + +namespace art { + +class HGraph; +class ExecutionSubgraph; + +class ExecutionSubgraphTestHelper { + public: + static bool CalculateValidity(HGraph* graph, const ExecutionSubgraph* subgraph); + + private: + ExecutionSubgraphTestHelper() = delete; + + DISALLOW_COPY_AND_ASSIGN(ExecutionSubgraphTestHelper); +}; +} // namespace art + +#endif // ART_COMPILER_OPTIMIZING_EXECUTION_SUBGRAPH_TEST_H_ -- cgit v1.2.3-59-g8ed1b