Optimizing: Refactor ImprovedOptimizingUnitTest.
And merge all functionality into OptimizingUnitTest.
Test: m test-art-host-gtest
Change-Id: I69a4e8c489462700ec0eb9ed93d5cdbdb6147f1a
diff --git a/compiler/optimizing/load_store_elimination_test.cc b/compiler/optimizing/load_store_elimination_test.cc
index 7380378..02cb633 100644
--- a/compiler/optimizing/load_store_elimination_test.cc
+++ b/compiler/optimizing/load_store_elimination_test.cc
@@ -26,7 +26,7 @@
namespace art {
-class LoadStoreEliminationTest : public ImprovedOptimizingUnitTest {
+class LoadStoreEliminationTest : public OptimizingUnitTest {
public:
void PerformLSE() {
graph_->BuildDominatorTree();
@@ -61,11 +61,9 @@
// |
// exit
void CreateTestControlFlowGraph() {
- pre_header_ = new (GetAllocator()) HBasicBlock(graph_);
- loop_ = new (GetAllocator()) HBasicBlock(graph_);
-
- graph_->AddBlock(pre_header_);
- graph_->AddBlock(loop_);
+ InitGraphAndParameters();
+ pre_header_ = AddNewBlock();
+ loop_ = AddNewBlock();
entry_block_->ReplaceSuccessor(return_block_, pre_header_);
pre_header_->AddSuccessor(loop_);
@@ -117,15 +115,12 @@
//
// Return: the basic blocks forming the CFG in the following order {upper, left, right, down}.
std::tuple<HBasicBlock*, HBasicBlock*, HBasicBlock*, HBasicBlock*> CreateDiamondShapedCFG() {
+ InitGraphAndParameters();
CreateEntryBlockInstructions();
- HBasicBlock* upper = new (GetAllocator()) HBasicBlock(graph_);
- HBasicBlock* left = new (GetAllocator()) HBasicBlock(graph_);
- HBasicBlock* right = new (GetAllocator()) HBasicBlock(graph_);
-
- graph_->AddBlock(upper);
- graph_->AddBlock(left);
- graph_->AddBlock(right);
+ HBasicBlock* upper = AddNewBlock();
+ HBasicBlock* left = AddNewBlock();
+ HBasicBlock* right = AddNewBlock();
entry_block_->ReplaceSuccessor(return_block_, upper);
upper->AddSuccessor(left);
@@ -232,21 +227,22 @@
return store;
}
- void CreateParameters() override {
- parameters_.push_back(new (GetAllocator()) HParameterValue(graph_->GetDexFile(),
- dex::TypeIndex(0),
- 0,
- DataType::Type::kInt32));
+ void InitGraphAndParameters() {
+ InitGraph();
+ AddParameter(new (GetAllocator()) HParameterValue(graph_->GetDexFile(),
+ dex::TypeIndex(0),
+ 0,
+ DataType::Type::kInt32));
array_ = parameters_.back();
- parameters_.push_back(new (GetAllocator()) HParameterValue(graph_->GetDexFile(),
- dex::TypeIndex(1),
- 1,
- DataType::Type::kInt32));
+ AddParameter(new (GetAllocator()) HParameterValue(graph_->GetDexFile(),
+ dex::TypeIndex(1),
+ 1,
+ DataType::Type::kInt32));
i_ = parameters_.back();
- parameters_.push_back(new (GetAllocator()) HParameterValue(graph_->GetDexFile(),
- dex::TypeIndex(1),
- 2,
- DataType::Type::kInt32));
+ AddParameter(new (GetAllocator()) HParameterValue(graph_->GetDexFile(),
+ dex::TypeIndex(1),
+ 2,
+ DataType::Type::kInt32));
j_ = parameters_.back();
}
@@ -264,7 +260,6 @@
};
TEST_F(LoadStoreEliminationTest, ArrayGetSetElimination) {
- InitGraph();
CreateTestControlFlowGraph();
HInstruction* c1 = graph_->GetIntConstant(1);
@@ -293,7 +288,6 @@
}
TEST_F(LoadStoreEliminationTest, SameHeapValue1) {
- InitGraph();
CreateTestControlFlowGraph();
HInstruction* c1 = graph_->GetIntConstant(1);
@@ -316,7 +310,6 @@
}
TEST_F(LoadStoreEliminationTest, SameHeapValue2) {
- InitGraph();
CreateTestControlFlowGraph();
// Test LSE handling same value stores on vector.
@@ -334,7 +327,6 @@
}
TEST_F(LoadStoreEliminationTest, SameHeapValue3) {
- InitGraph();
CreateTestControlFlowGraph();
// VecStore array[i...] = vdata;
@@ -350,7 +342,6 @@
}
TEST_F(LoadStoreEliminationTest, OverlappingLoadStore) {
- InitGraph();
CreateTestControlFlowGraph();
HInstruction* c1 = graph_->GetIntConstant(1);
@@ -408,7 +399,6 @@
// }
// a[j] = 1;
TEST_F(LoadStoreEliminationTest, StoreAfterLoopWithoutSideEffects) {
- InitGraph();
CreateTestControlFlowGraph();
HInstruction* c1 = graph_->GetIntConstant(1);
@@ -438,7 +428,6 @@
// a[j] = 0;
// }
TEST_F(LoadStoreEliminationTest, StoreAfterSIMDLoopWithSideEffects) {
- InitGraph();
CreateTestControlFlowGraph();
HInstruction* c0 = graph_->GetIntConstant(0);
@@ -477,7 +466,6 @@
// x = a[j];
// }
TEST_F(LoadStoreEliminationTest, LoadAfterSIMDLoopWithSideEffects) {
- InitGraph();
CreateTestControlFlowGraph();
HInstruction* c0 = graph_->GetIntConstant(0);
@@ -521,8 +509,6 @@
// 'vstore3' is not removed.
// 'vstore4' is not removed. Such cases are not supported at the moment.
TEST_F(LoadStoreEliminationTest, MergePredecessorVecStores) {
- InitGraph();
-
HBasicBlock* upper;
HBasicBlock* left;
HBasicBlock* right;
@@ -564,8 +550,6 @@
// 'store2' is not removed.
// 'store3' is removed.
TEST_F(LoadStoreEliminationTest, MergePredecessorStores) {
- InitGraph();
-
HBasicBlock* upper;
HBasicBlock* left;
HBasicBlock* right;
@@ -604,7 +588,6 @@
// 'vload' is removed.
// 'vstore3' is removed.
TEST_F(LoadStoreEliminationTest, RedundantVStoreVLoadInLoop) {
- InitGraph();
CreateTestControlFlowGraph();
HInstruction* c0 = graph_->GetIntConstant(0);
@@ -639,7 +622,6 @@
// This causes stores after such loops not to be removed, even
// their values are known.
TEST_F(LoadStoreEliminationTest, StoreAfterLoopWithSideEffects) {
- InitGraph();
CreateTestControlFlowGraph();
HInstruction* c0 = graph_->GetIntConstant(0);
@@ -669,7 +651,6 @@
// As it is not allowed to use defaults for VecLoads, check if there is a new created array
// a VecLoad used in a loop and after it is not replaced with a default.
TEST_F(LoadStoreEliminationTest, VLoadDefaultValueInLoopWithoutWriteSideEffects) {
- InitGraph();
CreateTestControlFlowGraph();
HInstruction* c0 = graph_->GetIntConstant(0);
@@ -694,7 +675,6 @@
// As it is not allowed to use defaults for VecLoads, check if there is a new created array
// a VecLoad is not replaced with a default.
TEST_F(LoadStoreEliminationTest, VLoadDefaultValue) {
- InitGraph();
CreateTestControlFlowGraph();
HInstruction* c0 = graph_->GetIntConstant(0);
@@ -718,7 +698,6 @@
// As it is allowed to use defaults for ordinary loads, check if there is a new created array
// a load used in a loop and after it is replaced with a default.
TEST_F(LoadStoreEliminationTest, LoadDefaultValueInLoopWithoutWriteSideEffects) {
- InitGraph();
CreateTestControlFlowGraph();
HInstruction* c0 = graph_->GetIntConstant(0);
@@ -743,7 +722,6 @@
// As it is allowed to use defaults for ordinary loads, check if there is a new created array
// a load is replaced with a default.
TEST_F(LoadStoreEliminationTest, LoadDefaultValue) {
- InitGraph();
CreateTestControlFlowGraph();
HInstruction* c0 = graph_->GetIntConstant(0);
@@ -768,7 +746,6 @@
// check if there is a new created array, a VecLoad and a load used in a loop and after it,
// VecLoad is not replaced with a default but the load is.
TEST_F(LoadStoreEliminationTest, VLoadAndLoadDefaultValueInLoopWithoutWriteSideEffects) {
- InitGraph();
CreateTestControlFlowGraph();
HInstruction* c0 = graph_->GetIntConstant(0);
@@ -800,7 +777,6 @@
// check if there is a new created array, a VecLoad and a load,
// VecLoad is not replaced with a default but the load is.
TEST_F(LoadStoreEliminationTest, VLoadAndLoadDefaultValue) {
- InitGraph();
CreateTestControlFlowGraph();
HInstruction* c0 = graph_->GetIntConstant(0);
@@ -831,7 +807,6 @@
// loads getting the same value.
// Check a load getting a known value is eliminated (a loop test case).
TEST_F(LoadStoreEliminationTest, VLoadDefaultValueAndVLoadInLoopWithoutWriteSideEffects) {
- InitGraph();
CreateTestControlFlowGraph();
HInstruction* c0 = graph_->GetIntConstant(0);
@@ -863,7 +838,6 @@
// loads getting the same value.
// Check a load getting a known value is eliminated.
TEST_F(LoadStoreEliminationTest, VLoadDefaultValueAndVLoad) {
- InitGraph();
CreateTestControlFlowGraph();
HInstruction* c0 = graph_->GetIntConstant(0);
diff --git a/compiler/optimizing/optimizing_unit_test.h b/compiler/optimizing/optimizing_unit_test.h
index 2c757f8..61e1680 100644
--- a/compiler/optimizing/optimizing_unit_test.h
+++ b/compiler/optimizing/optimizing_unit_test.h
@@ -109,7 +109,12 @@
// multiple inheritance errors from having two gtest as a parent twice.
class OptimizingUnitTestHelper {
public:
- OptimizingUnitTestHelper() : pool_and_allocator_(new ArenaPoolAndAllocator()) { }
+ OptimizingUnitTestHelper()
+ : pool_and_allocator_(new ArenaPoolAndAllocator()),
+ graph_(nullptr),
+ entry_block_(nullptr),
+ return_block_(nullptr),
+ exit_block_(nullptr) { }
ArenaAllocator* GetAllocator() { return pool_and_allocator_->GetAllocator(); }
ArenaStack* GetArenaStack() { return pool_and_allocator_->GetArenaStack(); }
@@ -136,13 +141,14 @@
/*oat_dex_file*/ nullptr,
/*container*/ nullptr));
- return new (allocator) HGraph(
+ graph_ = new (allocator) HGraph(
allocator,
pool_and_allocator_->GetArenaStack(),
handles,
*dex_files_.back(),
/*method_idx*/-1,
kRuntimeISA);
+ return graph_;
}
// Create a control-flow graph from Dex instructions.
@@ -177,6 +183,33 @@
}
}
+ void InitGraph() {
+ CreateGraph();
+ entry_block_ = AddNewBlock();
+ return_block_ = AddNewBlock();
+ exit_block_ = AddNewBlock();
+
+ graph_->SetEntryBlock(entry_block_);
+ graph_->SetExitBlock(exit_block_);
+
+ entry_block_->AddSuccessor(return_block_);
+ return_block_->AddSuccessor(exit_block_);
+
+ return_block_->AddInstruction(new (GetAllocator()) HReturnVoid());
+ exit_block_->AddInstruction(new (GetAllocator()) HExit());
+ }
+
+ void AddParameter(HInstruction* parameter) {
+ entry_block_->AddInstruction(parameter);
+ parameters_.push_back(parameter);
+ }
+
+ HBasicBlock* AddNewBlock() {
+ HBasicBlock* block = new (GetAllocator()) HBasicBlock(graph_);
+ graph_->AddBlock(block);
+ return block;
+ }
+
// Run GraphChecker with all checks.
//
// Return: the status whether the run is successful.
@@ -184,6 +217,10 @@
return CheckGraph(graph, /*check_ref_type_info=*/true);
}
+ bool CheckGraph() {
+ return CheckGraph(graph_);
+ }
+
// Run GraphChecker with all checks except reference type information checks.
//
// Return: the status whether the run is successful.
@@ -191,61 +228,8 @@
return CheckGraph(graph, /*check_ref_type_info=*/false);
}
- private:
- bool CheckGraph(HGraph* graph, bool check_ref_type_info) {
- GraphChecker checker(graph);
- checker.SetRefTypeInfoCheckEnabled(check_ref_type_info);
- checker.Run();
- checker.Dump(std::cerr);
- return checker.IsValid();
- }
-
- std::vector<std::unique_ptr<const StandardDexFile>> dex_files_;
- std::unique_ptr<ArenaPoolAndAllocator> pool_and_allocator_;
-};
-
-class OptimizingUnitTest : public CommonCompilerTest, public OptimizingUnitTestHelper {};
-
-// OptimizingUnitTest with some handy functions to ease the graph creation.
-class ImprovedOptimizingUnitTest : public OptimizingUnitTest {
- public:
- ImprovedOptimizingUnitTest() : graph_(CreateGraph()),
- entry_block_(nullptr),
- return_block_(nullptr),
- exit_block_(nullptr) {}
-
- virtual ~ImprovedOptimizingUnitTest() {}
-
- void InitGraph() {
- entry_block_ = new (GetAllocator()) HBasicBlock(graph_);
- graph_->AddBlock(entry_block_);
- graph_->SetEntryBlock(entry_block_);
-
- return_block_ = new (GetAllocator()) HBasicBlock(graph_);
- graph_->AddBlock(return_block_);
-
- exit_block_ = new (GetAllocator()) HBasicBlock(graph_);
- graph_->AddBlock(exit_block_);
- graph_->SetExitBlock(exit_block_);
-
- entry_block_->AddSuccessor(return_block_);
- return_block_->AddSuccessor(exit_block_);
-
- CreateParameters();
- for (HInstruction* parameter : parameters_) {
- entry_block_->AddInstruction(parameter);
- }
-
- return_block_->AddInstruction(new (GetAllocator()) HReturnVoid());
- exit_block_->AddInstruction(new (GetAllocator()) HExit());
- }
-
- bool CheckGraph() {
- return OptimizingUnitTestHelper::CheckGraph(graph_);
- }
-
bool CheckGraphSkipRefTypeInfoChecks() {
- return OptimizingUnitTestHelper::CheckGraphSkipRefTypeInfoChecks(graph_);
+ return CheckGraphSkipRefTypeInfoChecks(graph_);
}
HEnvironment* ManuallyBuildEnvFor(HInstruction* instruction,
@@ -263,12 +247,18 @@
}
protected:
- // Create parameters to be added to the graph entry block.
- // Subclasses can override it to create parameters they need.
- virtual void CreateParameters() { /* do nothing */ }
+ bool CheckGraph(HGraph* graph, bool check_ref_type_info) {
+ GraphChecker checker(graph);
+ checker.SetRefTypeInfoCheckEnabled(check_ref_type_info);
+ checker.Run();
+ checker.Dump(std::cerr);
+ return checker.IsValid();
+ }
+
+ std::vector<std::unique_ptr<const StandardDexFile>> dex_files_;
+ std::unique_ptr<ArenaPoolAndAllocator> pool_and_allocator_;
HGraph* graph_;
-
HBasicBlock* entry_block_;
HBasicBlock* return_block_;
HBasicBlock* exit_block_;
@@ -276,6 +266,8 @@
std::vector<HInstruction*> parameters_;
};
+class OptimizingUnitTest : public CommonCompilerTest, public OptimizingUnitTestHelper {};
+
// Naive string diff data type.
typedef std::list<std::pair<std::string, std::string>> diff_t;
diff --git a/compiler/optimizing/select_generator_test.cc b/compiler/optimizing/select_generator_test.cc
index 6e68c6c..b18d41a 100644
--- a/compiler/optimizing/select_generator_test.cc
+++ b/compiler/optimizing/select_generator_test.cc
@@ -24,24 +24,20 @@
namespace art {
-class SelectGeneratorTest : public ImprovedOptimizingUnitTest {
- private:
- void CreateParameters() override {
- parameters_.push_back(new (GetAllocator()) HParameterValue(graph_->GetDexFile(),
- dex::TypeIndex(0),
- 0,
- DataType::Type::kInt32));
+class SelectGeneratorTest : public OptimizingUnitTest {
+ protected:
+ void InitGraphAndParameters() {
+ InitGraph();
+ AddParameter(new (GetAllocator()) HParameterValue(graph_->GetDexFile(),
+ dex::TypeIndex(0),
+ 0,
+ DataType::Type::kInt32));
}
- public:
void ConstructBasicGraphForSelect(HInstruction* instr) {
- HBasicBlock* if_block = new (GetAllocator()) HBasicBlock(graph_);
- HBasicBlock* then_block = new (GetAllocator()) HBasicBlock(graph_);
- HBasicBlock* else_block = new (GetAllocator()) HBasicBlock(graph_);
-
- graph_->AddBlock(if_block);
- graph_->AddBlock(then_block);
- graph_->AddBlock(else_block);
+ HBasicBlock* if_block = AddNewBlock();
+ HBasicBlock* then_block = AddNewBlock();
+ HBasicBlock* else_block = AddNewBlock();
entry_block_->ReplaceSuccessor(return_block_, if_block);
@@ -82,7 +78,7 @@
// HDivZeroCheck might throw and should not be hoisted from the conditional to an unconditional.
TEST_F(SelectGeneratorTest, testZeroCheck) {
- InitGraph();
+ InitGraphAndParameters();
HDivZeroCheck* instr = new (GetAllocator()) HDivZeroCheck(parameters_[0], 0);
ConstructBasicGraphForSelect(instr);
@@ -95,7 +91,7 @@
// Test that SelectGenerator succeeds with HAdd.
TEST_F(SelectGeneratorTest, testAdd) {
- InitGraph();
+ InitGraphAndParameters();
HAdd* instr = new (GetAllocator()) HAdd(DataType::Type::kInt32,
parameters_[0],
parameters_[0], 0);
diff --git a/compiler/optimizing/superblock_cloner_test.cc b/compiler/optimizing/superblock_cloner_test.cc
index a46334b..d8d68b7 100644
--- a/compiler/optimizing/superblock_cloner_test.cc
+++ b/compiler/optimizing/superblock_cloner_test.cc
@@ -30,27 +30,23 @@
// This class provides methods and helpers for testing various cloning and copying routines:
// individual instruction cloning and cloning of the more coarse-grain structures.
-class SuperblockClonerTest : public ImprovedOptimizingUnitTest {
- private:
- void CreateParameters() override {
- parameters_.push_back(new (GetAllocator()) HParameterValue(graph_->GetDexFile(),
- dex::TypeIndex(0),
- 0,
- DataType::Type::kInt32));
+class SuperblockClonerTest : public OptimizingUnitTest {
+ protected:
+ void InitGraphAndParameters() {
+ InitGraph();
+ AddParameter(new (GetAllocator()) HParameterValue(graph_->GetDexFile(),
+ dex::TypeIndex(0),
+ 0,
+ DataType::Type::kInt32));
}
- public:
void CreateBasicLoopControlFlow(HBasicBlock* position,
HBasicBlock* successor,
/* out */ HBasicBlock** header_p,
/* out */ HBasicBlock** body_p) {
- HBasicBlock* loop_preheader = new (GetAllocator()) HBasicBlock(graph_);
- HBasicBlock* loop_header = new (GetAllocator()) HBasicBlock(graph_);
- HBasicBlock* loop_body = new (GetAllocator()) HBasicBlock(graph_);
-
- graph_->AddBlock(loop_preheader);
- graph_->AddBlock(loop_header);
- graph_->AddBlock(loop_body);
+ HBasicBlock* loop_preheader = AddNewBlock();
+ HBasicBlock* loop_header = AddNewBlock();
+ HBasicBlock* loop_body = AddNewBlock();
position->ReplaceSuccessor(successor, loop_preheader);
@@ -121,7 +117,7 @@
HBasicBlock* header = nullptr;
HBasicBlock* loop_body = nullptr;
- InitGraph();
+ InitGraphAndParameters();
CreateBasicLoopControlFlow(entry_block_, return_block_, &header, &loop_body);
CreateBasicLoopDataFlow(header, loop_body);
graph_->BuildDominatorTree();
@@ -151,9 +147,9 @@
TEST_F(SuperblockClonerTest, CloneBasicBlocks) {
HBasicBlock* header = nullptr;
HBasicBlock* loop_body = nullptr;
- ArenaAllocator* arena = graph_->GetAllocator();
+ ArenaAllocator* arena = GetAllocator();
- InitGraph();
+ InitGraphAndParameters();
CreateBasicLoopControlFlow(entry_block_, return_block_, &header, &loop_body);
CreateBasicLoopDataFlow(header, loop_body);
graph_->BuildDominatorTree();
@@ -232,9 +228,9 @@
TEST_F(SuperblockClonerTest, AdjustControlFlowInfo) {
HBasicBlock* header = nullptr;
HBasicBlock* loop_body = nullptr;
- ArenaAllocator* arena = graph_->GetAllocator();
+ ArenaAllocator* arena = GetAllocator();
- InitGraph();
+ InitGraphAndParameters();
CreateBasicLoopControlFlow(entry_block_, return_block_, &header, &loop_body);
CreateBasicLoopDataFlow(header, loop_body);
graph_->BuildDominatorTree();
@@ -271,13 +267,12 @@
TEST_F(SuperblockClonerTest, IsGraphConnected) {
HBasicBlock* header = nullptr;
HBasicBlock* loop_body = nullptr;
- ArenaAllocator* arena = graph_->GetAllocator();
+ ArenaAllocator* arena = GetAllocator();
- InitGraph();
+ InitGraphAndParameters();
CreateBasicLoopControlFlow(entry_block_, return_block_, &header, &loop_body);
CreateBasicLoopDataFlow(header, loop_body);
- HBasicBlock* unreachable_block = new (GetAllocator()) HBasicBlock(graph_);
- graph_->AddBlock(unreachable_block);
+ HBasicBlock* unreachable_block = AddNewBlock();
HBasicBlockSet bb_set(
arena, graph_->GetBlocks().size(), false, kArenaAllocSuperblockCloner);
@@ -297,7 +292,7 @@
HBasicBlock* header = nullptr;
HBasicBlock* loop_body = nullptr;
- InitGraph();
+ InitGraphAndParameters();
CreateBasicLoopControlFlow(entry_block_, return_block_, &header, &loop_body);
CreateBasicLoopDataFlow(header, loop_body);
graph_->BuildDominatorTree();
@@ -334,7 +329,7 @@
HBasicBlock* header = nullptr;
HBasicBlock* loop_body = nullptr;
- InitGraph();
+ InitGraphAndParameters();
CreateBasicLoopControlFlow(entry_block_, return_block_, &header, &loop_body);
CreateBasicLoopDataFlow(header, loop_body);
graph_->BuildDominatorTree();
@@ -371,7 +366,7 @@
HBasicBlock* header = nullptr;
HBasicBlock* loop_body = nullptr;
- InitGraph();
+ InitGraphAndParameters();
CreateBasicLoopControlFlow(entry_block_, return_block_, &header, &loop_body);
CreateBasicLoopDataFlow(header, loop_body);
graph_->BuildDominatorTree();
@@ -419,16 +414,14 @@
HBasicBlock* header = nullptr;
HBasicBlock* loop_body = nullptr;
- InitGraph();
+ InitGraphAndParameters();
CreateBasicLoopControlFlow(entry_block_, return_block_, &header, &loop_body);
CreateBasicLoopDataFlow(header, loop_body);
// Transform a basic loop to have multiple back edges.
HBasicBlock* latch = header->GetSuccessors()[1];
- HBasicBlock* if_block = new (GetAllocator()) HBasicBlock(graph_);
- HBasicBlock* temp1 = new (GetAllocator()) HBasicBlock(graph_);
- graph_->AddBlock(if_block);
- graph_->AddBlock(temp1);
+ HBasicBlock* if_block = AddNewBlock();
+ HBasicBlock* temp1 = AddNewBlock();
header->ReplaceSuccessor(latch, if_block);
if_block->AddSuccessor(latch);
if_block->AddSuccessor(temp1);
@@ -474,7 +467,7 @@
HBasicBlock* header = nullptr;
HBasicBlock* loop_body = nullptr;
- InitGraph();
+ InitGraphAndParameters();
// Create the following nested structure of loops
// Headers: 1 2 3
@@ -521,7 +514,7 @@
HBasicBlock* header = nullptr;
HBasicBlock* loop_body = nullptr;
- InitGraph();
+ InitGraphAndParameters();
// Create the following nested structure of loops
// Headers: 1 2 3 4
@@ -578,7 +571,7 @@
HBasicBlock* header = nullptr;
HBasicBlock* loop_body = nullptr;
- InitGraph();
+ InitGraphAndParameters();
// Create the following nested structure of loops then peel loop3.
// Headers: 1 2 3
@@ -597,8 +590,7 @@
HBasicBlock* loop_body3 = loop_body;
// Change the loop3 - insert an exit which leads to loop1.
- HBasicBlock* loop3_extra_if_block = new (GetAllocator()) HBasicBlock(graph_);
- graph_->AddBlock(loop3_extra_if_block);
+ HBasicBlock* loop3_extra_if_block = AddNewBlock();
loop3_extra_if_block->AddInstruction(new (GetAllocator()) HIf(parameters_[0]));
loop3_header->ReplaceSuccessor(loop_body3, loop3_extra_if_block);
@@ -631,9 +623,9 @@
TEST_F(SuperblockClonerTest, FastCaseCheck) {
HBasicBlock* header = nullptr;
HBasicBlock* loop_body = nullptr;
- ArenaAllocator* arena = graph_->GetAllocator();
+ ArenaAllocator* arena = GetAllocator();
- InitGraph();
+ InitGraphAndParameters();
CreateBasicLoopControlFlow(entry_block_, return_block_, &header, &loop_body);
CreateBasicLoopDataFlow(header, loop_body);
graph_->BuildDominatorTree();
@@ -688,7 +680,7 @@
HBasicBlock* header = nullptr;
HBasicBlock* loop_body = nullptr;
- InitGraph();
+ InitGraphAndParameters();
// Create the following nested structure of loops
// Headers: 1 2 3 4 5