From 5d2311a349f208f056b33da8fc9c950aad1a7ffe Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Wed, 13 May 2020 17:30:32 +0100 Subject: Optimizing: Refactor ImprovedOptimizingUnitTest. And merge all functionality into OptimizingUnitTest. Test: m test-art-host-gtest Change-Id: I69a4e8c489462700ec0eb9ed93d5cdbdb6147f1a --- compiler/optimizing/load_store_elimination_test.cc | 70 ++++--------- compiler/optimizing/optimizing_unit_test.h | 112 ++++++++++----------- compiler/optimizing/select_generator_test.cc | 30 +++--- compiler/optimizing/superblock_cloner_test.cc | 72 ++++++------- 4 files changed, 119 insertions(+), 165 deletions(-) (limited to 'compiler/optimizing') diff --git a/compiler/optimizing/load_store_elimination_test.cc b/compiler/optimizing/load_store_elimination_test.cc index 738037803e..02cb6336b6 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 @@ class LoadStoreEliminationTest : public ImprovedOptimizingUnitTest { // | // 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 @@ class LoadStoreEliminationTest : public ImprovedOptimizingUnitTest { // // Return: the basic blocks forming the CFG in the following order {upper, left, right, down}. std::tuple 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 @@ class LoadStoreEliminationTest : public ImprovedOptimizingUnitTest { 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 @@ class LoadStoreEliminationTest : public ImprovedOptimizingUnitTest { }; TEST_F(LoadStoreEliminationTest, ArrayGetSetElimination) { - InitGraph(); CreateTestControlFlowGraph(); HInstruction* c1 = graph_->GetIntConstant(1); @@ -293,7 +288,6 @@ TEST_F(LoadStoreEliminationTest, ArrayGetSetElimination) { } TEST_F(LoadStoreEliminationTest, SameHeapValue1) { - InitGraph(); CreateTestControlFlowGraph(); HInstruction* c1 = graph_->GetIntConstant(1); @@ -316,7 +310,6 @@ TEST_F(LoadStoreEliminationTest, SameHeapValue1) { } TEST_F(LoadStoreEliminationTest, SameHeapValue2) { - InitGraph(); CreateTestControlFlowGraph(); // Test LSE handling same value stores on vector. @@ -334,7 +327,6 @@ TEST_F(LoadStoreEliminationTest, SameHeapValue2) { } TEST_F(LoadStoreEliminationTest, SameHeapValue3) { - InitGraph(); CreateTestControlFlowGraph(); // VecStore array[i...] = vdata; @@ -350,7 +342,6 @@ TEST_F(LoadStoreEliminationTest, SameHeapValue3) { } TEST_F(LoadStoreEliminationTest, OverlappingLoadStore) { - InitGraph(); CreateTestControlFlowGraph(); HInstruction* c1 = graph_->GetIntConstant(1); @@ -408,7 +399,6 @@ TEST_F(LoadStoreEliminationTest, OverlappingLoadStore) { // } // a[j] = 1; TEST_F(LoadStoreEliminationTest, StoreAfterLoopWithoutSideEffects) { - InitGraph(); CreateTestControlFlowGraph(); HInstruction* c1 = graph_->GetIntConstant(1); @@ -438,7 +428,6 @@ TEST_F(LoadStoreEliminationTest, StoreAfterLoopWithoutSideEffects) { // a[j] = 0; // } TEST_F(LoadStoreEliminationTest, StoreAfterSIMDLoopWithSideEffects) { - InitGraph(); CreateTestControlFlowGraph(); HInstruction* c0 = graph_->GetIntConstant(0); @@ -477,7 +466,6 @@ TEST_F(LoadStoreEliminationTest, StoreAfterSIMDLoopWithSideEffects) { // x = a[j]; // } TEST_F(LoadStoreEliminationTest, LoadAfterSIMDLoopWithSideEffects) { - InitGraph(); CreateTestControlFlowGraph(); HInstruction* c0 = graph_->GetIntConstant(0); @@ -521,8 +509,6 @@ TEST_F(LoadStoreEliminationTest, LoadAfterSIMDLoopWithSideEffects) { // '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 @@ TEST_F(LoadStoreEliminationTest, MergePredecessorVecStores) { // 'store2' is not removed. // 'store3' is removed. TEST_F(LoadStoreEliminationTest, MergePredecessorStores) { - InitGraph(); - HBasicBlock* upper; HBasicBlock* left; HBasicBlock* right; @@ -604,7 +588,6 @@ TEST_F(LoadStoreEliminationTest, MergePredecessorStores) { // 'vload' is removed. // 'vstore3' is removed. TEST_F(LoadStoreEliminationTest, RedundantVStoreVLoadInLoop) { - InitGraph(); CreateTestControlFlowGraph(); HInstruction* c0 = graph_->GetIntConstant(0); @@ -639,7 +622,6 @@ TEST_F(LoadStoreEliminationTest, RedundantVStoreVLoadInLoop) { // 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 @@ TEST_F(LoadStoreEliminationTest, StoreAfterLoopWithSideEffects) { // 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 @@ TEST_F(LoadStoreEliminationTest, VLoadDefaultValueInLoopWithoutWriteSideEffects) // 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 @@ TEST_F(LoadStoreEliminationTest, VLoadDefaultValue) { // 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 @@ TEST_F(LoadStoreEliminationTest, LoadDefaultValueInLoopWithoutWriteSideEffects) // 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 @@ TEST_F(LoadStoreEliminationTest, LoadDefaultValue) { // 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 @@ TEST_F(LoadStoreEliminationTest, VLoadAndLoadDefaultValueInLoopWithoutWriteSideE // 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 @@ TEST_F(LoadStoreEliminationTest, VLoadAndLoadDefaultValue) { // 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 @@ TEST_F(LoadStoreEliminationTest, VLoadDefaultValueAndVLoadInLoopWithoutWriteSide // 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 2c757f8535..61e16800e5 100644 --- a/compiler/optimizing/optimizing_unit_test.h +++ b/compiler/optimizing/optimizing_unit_test.h @@ -109,7 +109,12 @@ class ArenaPoolAndAllocator { // 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 @@ class OptimizingUnitTestHelper { /*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,75 +183,53 @@ class OptimizingUnitTestHelper { } } - // Run GraphChecker with all checks. - // - // Return: the status whether the run is successful. - bool CheckGraph(HGraph* graph) { - return CheckGraph(graph, /*check_ref_type_info=*/true); - } - - // Run GraphChecker with all checks except reference type information checks. - // - // Return: the status whether the run is successful. - bool CheckGraphSkipRefTypeInfoChecks(HGraph* graph) { - 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> dex_files_; - std::unique_ptr 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_); + CreateGraph(); + entry_block_ = AddNewBlock(); + return_block_ = AddNewBlock(); + exit_block_ = AddNewBlock(); - exit_block_ = new (GetAllocator()) HBasicBlock(graph_); - graph_->AddBlock(exit_block_); + graph_->SetEntryBlock(entry_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()); } + 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. + bool CheckGraph(HGraph* graph) { + return CheckGraph(graph, /*check_ref_type_info=*/true); + } + bool CheckGraph() { - return OptimizingUnitTestHelper::CheckGraph(graph_); + return CheckGraph(graph_); + } + + // Run GraphChecker with all checks except reference type information checks. + // + // Return: the status whether the run is successful. + bool CheckGraphSkipRefTypeInfoChecks(HGraph* graph) { + return CheckGraph(graph, /*check_ref_type_info=*/false); } bool CheckGraphSkipRefTypeInfoChecks() { - return OptimizingUnitTestHelper::CheckGraphSkipRefTypeInfoChecks(graph_); + return CheckGraphSkipRefTypeInfoChecks(graph_); } HEnvironment* ManuallyBuildEnvFor(HInstruction* instruction, @@ -263,12 +247,18 @@ class ImprovedOptimizingUnitTest : public OptimizingUnitTest { } 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(); + } - HGraph* graph_; + std::vector> dex_files_; + std::unique_ptr pool_and_allocator_; + HGraph* graph_; HBasicBlock* entry_block_; HBasicBlock* return_block_; HBasicBlock* exit_block_; @@ -276,6 +266,8 @@ class ImprovedOptimizingUnitTest : public OptimizingUnitTest { std::vector parameters_; }; +class OptimizingUnitTest : public CommonCompilerTest, public OptimizingUnitTestHelper {}; + // Naive string diff data type. typedef std::list> diff_t; diff --git a/compiler/optimizing/select_generator_test.cc b/compiler/optimizing/select_generator_test.cc index 6e68c6c80d..b18d41abbb 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 @@ class SelectGeneratorTest : public ImprovedOptimizingUnitTest { // 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_F(SelectGeneratorTest, testZeroCheck) { // 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 a46334bfca..d8d68b7763 100644 --- a/compiler/optimizing/superblock_cloner_test.cc +++ b/compiler/optimizing/superblock_cloner_test.cc @@ -30,27 +30,23 @@ using HEdgeSet = SuperblockCloner::HEdgeSet; // 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 @@ TEST_F(SuperblockClonerTest, IndividualInstrCloner) { 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, IndividualInstrCloner) { 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, CloneBasicBlocks) { 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, AdjustControlFlowInfo) { 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 @@ TEST_F(SuperblockClonerTest, LoopPeeling) { 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 @@ TEST_F(SuperblockClonerTest, LoopUnrolling) { 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 @@ TEST_F(SuperblockClonerTest, LoopVersioning) { 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 @@ TEST_F(SuperblockClonerTest, LoopPeelingMultipleBackEdges) { 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 @@ TEST_F(SuperblockClonerTest, LoopPeelingNested) { HBasicBlock* header = nullptr; HBasicBlock* loop_body = nullptr; - InitGraph(); + InitGraphAndParameters(); // Create the following nested structure of loops // Headers: 1 2 3 @@ -521,7 +514,7 @@ TEST_F(SuperblockClonerTest, OuterLoopPopulationAfterInnerPeeled) { 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 @@ TEST_F(SuperblockClonerTest, NestedCaseExitToOutermost) { 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 @@ TEST_F(SuperblockClonerTest, NestedCaseExitToOutermost) { 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, NestedCaseExitToOutermost) { 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 @@ TEST_F(SuperblockClonerTest, FindCommonLoop) { HBasicBlock* header = nullptr; HBasicBlock* loop_body = nullptr; - InitGraph(); + InitGraphAndParameters(); // Create the following nested structure of loops // Headers: 1 2 3 4 5 -- cgit v1.2.3-59-g8ed1b