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