Add ImprovedOptimizingUnitTest::CreateParameters for subclasses
Subclasses of ImprovedOptimizingUnitTest might need a different number
of graph parameters. Currently only a parameter is defined and created.
This CL adds ImprovedOptimizingUnitTest::CreateParameters which
subclasses can override to create as many parameters as they need. All
created parameters are added to the entry basic block. The default
implementation of ImprovedOptimizingUnitTest::CreateParameters does
nothing.
Test: run-gtests.sh
Change-Id: I2c6a58232e36d3562fc2bc0cdc289dd739094a73
diff --git a/compiler/optimizing/superblock_cloner_test.cc b/compiler/optimizing/superblock_cloner_test.cc
index aa19de6..ddcf154 100644
--- a/compiler/optimizing/superblock_cloner_test.cc
+++ b/compiler/optimizing/superblock_cloner_test.cc
@@ -31,6 +31,14 @@
// 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));
+ }
+
public:
void CreateBasicLoopControlFlow(HBasicBlock* position,
HBasicBlock* successor,
@@ -75,7 +83,7 @@
loop_header->AddInstruction(new (GetAllocator()) HIf(loop_check));
// Loop body block.
- HInstruction* null_check = new (GetAllocator()) HNullCheck(parameter_, dex_pc);
+ HInstruction* null_check = new (GetAllocator()) HNullCheck(parameters_[0], dex_pc);
HInstruction* array_length = new (GetAllocator()) HArrayLength(null_check, dex_pc);
HInstruction* bounds_check = new (GetAllocator()) HBoundsCheck(phi, array_length, dex_pc);
HInstruction* array_get =
@@ -100,7 +108,7 @@
graph_->SetHasBoundsChecks(true);
// Adjust HEnvironment for each instruction which require that.
- ArenaVector<HInstruction*> current_locals({phi, const_128, parameter_},
+ ArenaVector<HInstruction*> current_locals({phi, const_128, parameters_[0]},
GetAllocator()->Adapter(kArenaAllocInstruction));
HEnvironment* env = ManuallyBuildEnvFor(suspend_check, ¤t_locals);
@@ -421,7 +429,7 @@
if_block->AddSuccessor(temp1);
temp1->AddSuccessor(header);
- if_block->AddInstruction(new (GetAllocator()) HIf(parameter_));
+ if_block->AddInstruction(new (GetAllocator()) HIf(parameters_[0]));
HInstructionIterator it(header->GetPhis());
DCHECK(!it.Done());
@@ -586,7 +594,7 @@
// 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);
- loop3_extra_if_block->AddInstruction(new (GetAllocator()) HIf(parameter_));
+ loop3_extra_if_block->AddInstruction(new (GetAllocator()) HIf(parameters_[0]));
loop3_header->ReplaceSuccessor(loop_body3, loop3_extra_if_block);
loop3_extra_if_block->AddSuccessor(loop_body1); // Long exit.