Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Andreas Gampe | 8cf9cb3 | 2017-07-19 09:28:38 -0700 | [diff] [blame] | 17 | #include "ssa_liveness_analysis.h" |
| 18 | |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 19 | #include "arch/instruction_set.h" |
| 20 | #include "arch/instruction_set_features.h" |
| 21 | #include "base/arena_allocator.h" |
| 22 | #include "base/arena_containers.h" |
Vladimír Marko | 434d968 | 2022-11-04 14:04:17 +0000 | [diff] [blame] | 23 | #include "base/macros.h" |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 24 | #include "code_generator.h" |
Andreas Gampe | 8cf9cb3 | 2017-07-19 09:28:38 -0700 | [diff] [blame] | 25 | #include "driver/compiler_options.h" |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 26 | #include "nodes.h" |
| 27 | #include "optimizing_unit_test.h" |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 28 | |
Vladimír Marko | 434d968 | 2022-11-04 14:04:17 +0000 | [diff] [blame] | 29 | namespace art HIDDEN { |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 30 | |
Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 31 | class SsaLivenessAnalysisTest : public OptimizingUnitTest { |
Vladimir Marko | a043111 | 2018-06-25 09:32:54 +0100 | [diff] [blame] | 32 | protected: |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 33 | void SetUp() override { |
Vladimir Marko | a043111 | 2018-06-25 09:32:54 +0100 | [diff] [blame] | 34 | OptimizingUnitTest::SetUp(); |
| 35 | graph_ = CreateGraph(); |
Vladimir Marko | f91fc12 | 2020-05-13 09:21:00 +0100 | [diff] [blame] | 36 | compiler_options_ = CommonCompilerTest::CreateCompilerOptions(kRuntimeISA, "default"); |
Vladimir Marko | a043111 | 2018-06-25 09:32:54 +0100 | [diff] [blame] | 37 | codegen_ = CodeGenerator::Create(graph_, *compiler_options_); |
Vladimir Marko | f91fc12 | 2020-05-13 09:21:00 +0100 | [diff] [blame] | 38 | CHECK(codegen_ != nullptr); |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 39 | // Create entry block. |
Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 40 | entry_ = new (GetAllocator()) HBasicBlock(graph_); |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 41 | graph_->AddBlock(entry_); |
| 42 | graph_->SetEntryBlock(entry_); |
| 43 | } |
| 44 | |
| 45 | protected: |
| 46 | HBasicBlock* CreateSuccessor(HBasicBlock* block) { |
| 47 | HGraph* graph = block->GetGraph(); |
Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 48 | HBasicBlock* successor = new (GetAllocator()) HBasicBlock(graph); |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 49 | graph->AddBlock(successor); |
| 50 | block->AddSuccessor(successor); |
| 51 | return successor; |
| 52 | } |
| 53 | |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 54 | HGraph* graph_; |
Vladimir Marko | f91fc12 | 2020-05-13 09:21:00 +0100 | [diff] [blame] | 55 | std::unique_ptr<CompilerOptions> compiler_options_; |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 56 | std::unique_ptr<CodeGenerator> codegen_; |
| 57 | HBasicBlock* entry_; |
| 58 | }; |
| 59 | |
| 60 | TEST_F(SsaLivenessAnalysisTest, TestReturnArg) { |
Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 61 | HInstruction* arg = new (GetAllocator()) HParameterValue( |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 62 | graph_->GetDexFile(), dex::TypeIndex(0), 0, DataType::Type::kInt32); |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 63 | entry_->AddInstruction(arg); |
| 64 | |
| 65 | HBasicBlock* block = CreateSuccessor(entry_); |
Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 66 | HInstruction* ret = new (GetAllocator()) HReturn(arg); |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 67 | block->AddInstruction(ret); |
Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 68 | block->AddInstruction(new (GetAllocator()) HExit()); |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 69 | |
| 70 | graph_->BuildDominatorTree(); |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 71 | SsaLivenessAnalysis ssa_analysis(graph_, codegen_.get(), GetScopedAllocator()); |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 72 | ssa_analysis.Analyze(); |
| 73 | |
| 74 | std::ostringstream arg_dump; |
| 75 | arg->GetLiveInterval()->Dump(arg_dump); |
| 76 | EXPECT_STREQ("ranges: { [2,6) }, uses: { 6 }, { } is_fixed: 0, is_split: 0 is_low: 0 is_high: 0", |
| 77 | arg_dump.str().c_str()); |
| 78 | } |
| 79 | |
| 80 | TEST_F(SsaLivenessAnalysisTest, TestAput) { |
Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 81 | HInstruction* array = new (GetAllocator()) HParameterValue( |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 82 | graph_->GetDexFile(), dex::TypeIndex(0), 0, DataType::Type::kReference); |
Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 83 | HInstruction* index = new (GetAllocator()) HParameterValue( |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 84 | graph_->GetDexFile(), dex::TypeIndex(1), 1, DataType::Type::kInt32); |
Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 85 | HInstruction* value = new (GetAllocator()) HParameterValue( |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 86 | graph_->GetDexFile(), dex::TypeIndex(2), 2, DataType::Type::kInt32); |
Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 87 | HInstruction* extra_arg1 = new (GetAllocator()) HParameterValue( |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 88 | graph_->GetDexFile(), dex::TypeIndex(3), 3, DataType::Type::kInt32); |
Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 89 | HInstruction* extra_arg2 = new (GetAllocator()) HParameterValue( |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 90 | graph_->GetDexFile(), dex::TypeIndex(4), 4, DataType::Type::kReference); |
Vladimir Marko | 69d310e | 2017-10-09 14:12:23 +0100 | [diff] [blame] | 91 | HInstruction* const args[] = { array, index, value, extra_arg1, extra_arg2 }; |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 92 | for (HInstruction* insn : args) { |
| 93 | entry_->AddInstruction(insn); |
| 94 | } |
| 95 | |
| 96 | HBasicBlock* block = CreateSuccessor(entry_); |
Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 97 | HInstruction* null_check = new (GetAllocator()) HNullCheck(array, 0); |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 98 | block->AddInstruction(null_check); |
Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 99 | HEnvironment* null_check_env = new (GetAllocator()) HEnvironment(GetAllocator(), |
Andreas Gampe | 3db7068 | 2018-12-26 15:12:03 -0800 | [diff] [blame] | 100 | /* number_of_vregs= */ 5, |
| 101 | /* method= */ nullptr, |
| 102 | /* dex_pc= */ 0u, |
Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 103 | null_check); |
Vladimir Marko | 69d310e | 2017-10-09 14:12:23 +0100 | [diff] [blame] | 104 | null_check_env->CopyFrom(ArrayRef<HInstruction* const>(args)); |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 105 | null_check->SetRawEnvironment(null_check_env); |
Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 106 | HInstruction* length = new (GetAllocator()) HArrayLength(array, 0); |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 107 | block->AddInstruction(length); |
Andreas Gampe | 3db7068 | 2018-12-26 15:12:03 -0800 | [diff] [blame] | 108 | HInstruction* bounds_check = new (GetAllocator()) HBoundsCheck(index, length, /* dex_pc= */ 0u); |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 109 | block->AddInstruction(bounds_check); |
Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 110 | HEnvironment* bounds_check_env = new (GetAllocator()) HEnvironment(GetAllocator(), |
Andreas Gampe | 3db7068 | 2018-12-26 15:12:03 -0800 | [diff] [blame] | 111 | /* number_of_vregs= */ 5, |
| 112 | /* method= */ nullptr, |
| 113 | /* dex_pc= */ 0u, |
Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 114 | bounds_check); |
Vladimir Marko | 69d310e | 2017-10-09 14:12:23 +0100 | [diff] [blame] | 115 | bounds_check_env->CopyFrom(ArrayRef<HInstruction* const>(args)); |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 116 | bounds_check->SetRawEnvironment(bounds_check_env); |
| 117 | HInstruction* array_set = |
Andreas Gampe | 3db7068 | 2018-12-26 15:12:03 -0800 | [diff] [blame] | 118 | new (GetAllocator()) HArraySet(array, index, value, DataType::Type::kInt32, /* dex_pc= */ 0); |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 119 | block->AddInstruction(array_set); |
| 120 | |
| 121 | graph_->BuildDominatorTree(); |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 122 | SsaLivenessAnalysis ssa_analysis(graph_, codegen_.get(), GetScopedAllocator()); |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 123 | ssa_analysis.Analyze(); |
| 124 | |
| 125 | EXPECT_FALSE(graph_->IsDebuggable()); |
| 126 | EXPECT_EQ(18u, bounds_check->GetLifetimePosition()); |
| 127 | static const char* const expected[] = { |
| 128 | "ranges: { [2,21) }, uses: { 15 17 21 }, { 15 19 } is_fixed: 0, is_split: 0 is_low: 0 " |
| 129 | "is_high: 0", |
Artem Serov | d675053 | 2018-05-30 20:07:43 +0100 | [diff] [blame] | 130 | "ranges: { [4,21) }, uses: { 19 21 }, { } is_fixed: 0, is_split: 0 is_low: 0 " |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 131 | "is_high: 0", |
Artem Serov | d675053 | 2018-05-30 20:07:43 +0100 | [diff] [blame] | 132 | "ranges: { [6,21) }, uses: { 21 }, { } is_fixed: 0, is_split: 0 is_low: 0 " |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 133 | "is_high: 0", |
| 134 | // Environment uses do not keep the non-reference argument alive. |
Artem Serov | d675053 | 2018-05-30 20:07:43 +0100 | [diff] [blame] | 135 | "ranges: { [8,10) }, uses: { }, { } is_fixed: 0, is_split: 0 is_low: 0 is_high: 0", |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 136 | // Environment uses keep the reference argument alive. |
| 137 | "ranges: { [10,19) }, uses: { }, { 15 19 } is_fixed: 0, is_split: 0 is_low: 0 is_high: 0", |
| 138 | }; |
Vladimir Marko | 69d310e | 2017-10-09 14:12:23 +0100 | [diff] [blame] | 139 | static_assert(arraysize(expected) == arraysize(args), "Array size check."); |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 140 | size_t arg_index = 0u; |
| 141 | for (HInstruction* arg : args) { |
| 142 | std::ostringstream arg_dump; |
| 143 | arg->GetLiveInterval()->Dump(arg_dump); |
| 144 | EXPECT_STREQ(expected[arg_index], arg_dump.str().c_str()) << arg_index; |
| 145 | ++arg_index; |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | TEST_F(SsaLivenessAnalysisTest, TestDeoptimize) { |
Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 150 | HInstruction* array = new (GetAllocator()) HParameterValue( |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 151 | graph_->GetDexFile(), dex::TypeIndex(0), 0, DataType::Type::kReference); |
Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 152 | HInstruction* index = new (GetAllocator()) HParameterValue( |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 153 | graph_->GetDexFile(), dex::TypeIndex(1), 1, DataType::Type::kInt32); |
Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 154 | HInstruction* value = new (GetAllocator()) HParameterValue( |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 155 | graph_->GetDexFile(), dex::TypeIndex(2), 2, DataType::Type::kInt32); |
Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 156 | HInstruction* extra_arg1 = new (GetAllocator()) HParameterValue( |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 157 | graph_->GetDexFile(), dex::TypeIndex(3), 3, DataType::Type::kInt32); |
Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 158 | HInstruction* extra_arg2 = new (GetAllocator()) HParameterValue( |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 159 | graph_->GetDexFile(), dex::TypeIndex(4), 4, DataType::Type::kReference); |
Vladimir Marko | 69d310e | 2017-10-09 14:12:23 +0100 | [diff] [blame] | 160 | HInstruction* const args[] = { array, index, value, extra_arg1, extra_arg2 }; |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 161 | for (HInstruction* insn : args) { |
| 162 | entry_->AddInstruction(insn); |
| 163 | } |
| 164 | |
| 165 | HBasicBlock* block = CreateSuccessor(entry_); |
Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 166 | HInstruction* null_check = new (GetAllocator()) HNullCheck(array, 0); |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 167 | block->AddInstruction(null_check); |
Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 168 | HEnvironment* null_check_env = new (GetAllocator()) HEnvironment(GetAllocator(), |
Andreas Gampe | 3db7068 | 2018-12-26 15:12:03 -0800 | [diff] [blame] | 169 | /* number_of_vregs= */ 5, |
| 170 | /* method= */ nullptr, |
| 171 | /* dex_pc= */ 0u, |
Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 172 | null_check); |
Vladimir Marko | 69d310e | 2017-10-09 14:12:23 +0100 | [diff] [blame] | 173 | null_check_env->CopyFrom(ArrayRef<HInstruction* const>(args)); |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 174 | null_check->SetRawEnvironment(null_check_env); |
Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 175 | HInstruction* length = new (GetAllocator()) HArrayLength(array, 0); |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 176 | block->AddInstruction(length); |
| 177 | // Use HAboveOrEqual+HDeoptimize as the bounds check. |
Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 178 | HInstruction* ae = new (GetAllocator()) HAboveOrEqual(index, length); |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 179 | block->AddInstruction(ae); |
Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 180 | HInstruction* deoptimize = new(GetAllocator()) HDeoptimize( |
Andreas Gampe | 3db7068 | 2018-12-26 15:12:03 -0800 | [diff] [blame] | 181 | GetAllocator(), ae, DeoptimizationKind::kBlockBCE, /* dex_pc= */ 0u); |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 182 | block->AddInstruction(deoptimize); |
Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 183 | HEnvironment* deoptimize_env = new (GetAllocator()) HEnvironment(GetAllocator(), |
Andreas Gampe | 3db7068 | 2018-12-26 15:12:03 -0800 | [diff] [blame] | 184 | /* number_of_vregs= */ 5, |
| 185 | /* method= */ nullptr, |
| 186 | /* dex_pc= */ 0u, |
Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 187 | deoptimize); |
Vladimir Marko | 69d310e | 2017-10-09 14:12:23 +0100 | [diff] [blame] | 188 | deoptimize_env->CopyFrom(ArrayRef<HInstruction* const>(args)); |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 189 | deoptimize->SetRawEnvironment(deoptimize_env); |
| 190 | HInstruction* array_set = |
Andreas Gampe | 3db7068 | 2018-12-26 15:12:03 -0800 | [diff] [blame] | 191 | new (GetAllocator()) HArraySet(array, index, value, DataType::Type::kInt32, /* dex_pc= */ 0); |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 192 | block->AddInstruction(array_set); |
| 193 | |
| 194 | graph_->BuildDominatorTree(); |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 195 | SsaLivenessAnalysis ssa_analysis(graph_, codegen_.get(), GetScopedAllocator()); |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 196 | ssa_analysis.Analyze(); |
| 197 | |
| 198 | EXPECT_FALSE(graph_->IsDebuggable()); |
| 199 | EXPECT_EQ(20u, deoptimize->GetLifetimePosition()); |
| 200 | static const char* const expected[] = { |
| 201 | "ranges: { [2,23) }, uses: { 15 17 23 }, { 15 21 } is_fixed: 0, is_split: 0 is_low: 0 " |
| 202 | "is_high: 0", |
Artem Serov | d675053 | 2018-05-30 20:07:43 +0100 | [diff] [blame] | 203 | "ranges: { [4,23) }, uses: { 19 23 }, { 21 } is_fixed: 0, is_split: 0 is_low: 0 " |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 204 | "is_high: 0", |
Artem Serov | d675053 | 2018-05-30 20:07:43 +0100 | [diff] [blame] | 205 | "ranges: { [6,23) }, uses: { 23 }, { 21 } is_fixed: 0, is_split: 0 is_low: 0 is_high: 0", |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 206 | // Environment use in HDeoptimize keeps even the non-reference argument alive. |
Artem Serov | d675053 | 2018-05-30 20:07:43 +0100 | [diff] [blame] | 207 | "ranges: { [8,21) }, uses: { }, { 21 } is_fixed: 0, is_split: 0 is_low: 0 is_high: 0", |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 208 | // Environment uses keep the reference argument alive. |
| 209 | "ranges: { [10,21) }, uses: { }, { 15 21 } is_fixed: 0, is_split: 0 is_low: 0 is_high: 0", |
| 210 | }; |
Vladimir Marko | 69d310e | 2017-10-09 14:12:23 +0100 | [diff] [blame] | 211 | static_assert(arraysize(expected) == arraysize(args), "Array size check."); |
Vladimir Marko | 356bd28 | 2017-03-01 12:01:11 +0000 | [diff] [blame] | 212 | size_t arg_index = 0u; |
| 213 | for (HInstruction* arg : args) { |
| 214 | std::ostringstream arg_dump; |
| 215 | arg->GetLiveInterval()->Dump(arg_dump); |
| 216 | EXPECT_STREQ(expected[arg_index], arg_dump.str().c_str()) << arg_index; |
| 217 | ++arg_index; |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | } // namespace art |