From 104fd8a3f30ddcf07831250571aa2a233cd5c04d Mon Sep 17 00:00:00 2001 From: "Guillaume \"Vermeille\" Sanchez" Date: Wed, 20 May 2015 17:52:13 +0100 Subject: Bring Reference Type Propagation to Instance/StaticInstanceField For this, we need the field index in FieldInfo, hence the add of the field. Change-Id: Id219bd826d8496acf3981307a8c42e2eb6ddb712 --- compiler/optimizing/gvn_test.cc | 153 ++++++++++++++++++++++++++++------------ 1 file changed, 107 insertions(+), 46 deletions(-) (limited to 'compiler/optimizing/gvn_test.cc') diff --git a/compiler/optimizing/gvn_test.cc b/compiler/optimizing/gvn_test.cc index c3ce7e142a..d8a09ffc38 100644 --- a/compiler/optimizing/gvn_test.cc +++ b/compiler/optimizing/gvn_test.cc @@ -40,23 +40,40 @@ TEST(GVNTest, LocalFieldElimination) { graph->AddBlock(block); entry->AddSuccessor(block); - block->AddInstruction( - new (&allocator) HInstanceFieldGet(parameter, Primitive::kPrimNot, - MemberOffset(42), false)); - block->AddInstruction( - new (&allocator) HInstanceFieldGet(parameter, Primitive::kPrimNot, - MemberOffset(42), false)); + block->AddInstruction(new (&allocator) HInstanceFieldGet(parameter, + Primitive::kPrimNot, + MemberOffset(42), + false, + kUnknownFieldIndex, + graph->GetDexFile())); + block->AddInstruction(new (&allocator) HInstanceFieldGet(parameter, + Primitive::kPrimNot, + MemberOffset(42), + false, + kUnknownFieldIndex, + graph->GetDexFile())); HInstruction* to_remove = block->GetLastInstruction(); - block->AddInstruction( - new (&allocator) HInstanceFieldGet(parameter, Primitive::kPrimNot, - MemberOffset(43), false)); + block->AddInstruction(new (&allocator) HInstanceFieldGet(parameter, + Primitive::kPrimNot, + MemberOffset(43), + false, + kUnknownFieldIndex, + graph->GetDexFile())); HInstruction* different_offset = block->GetLastInstruction(); // Kill the value. - block->AddInstruction(new (&allocator) HInstanceFieldSet( - parameter, parameter, Primitive::kPrimNot, MemberOffset(42), false)); - block->AddInstruction( - new (&allocator) HInstanceFieldGet(parameter, Primitive::kPrimNot, - MemberOffset(42), false)); + block->AddInstruction(new (&allocator) HInstanceFieldSet(parameter, + parameter, + Primitive::kPrimNot, + MemberOffset(42), + false, + kUnknownFieldIndex, + graph->GetDexFile())); + block->AddInstruction(new (&allocator) HInstanceFieldGet(parameter, + Primitive::kPrimNot, + MemberOffset(42), + false, + kUnknownFieldIndex, + graph->GetDexFile())); HInstruction* use_after_kill = block->GetLastInstruction(); block->AddInstruction(new (&allocator) HExit()); @@ -88,9 +105,12 @@ TEST(GVNTest, GlobalFieldElimination) { HBasicBlock* block = new (&allocator) HBasicBlock(graph); graph->AddBlock(block); entry->AddSuccessor(block); - block->AddInstruction( - new (&allocator) HInstanceFieldGet(parameter, Primitive::kPrimBoolean, - MemberOffset(42), false)); + block->AddInstruction(new (&allocator) HInstanceFieldGet(parameter, + Primitive::kPrimBoolean, + MemberOffset(42), + false, + kUnknownFieldIndex, + graph->GetDexFile())); block->AddInstruction(new (&allocator) HIf(block->GetLastInstruction())); HBasicBlock* then = new (&allocator) HBasicBlock(graph); @@ -105,17 +125,26 @@ TEST(GVNTest, GlobalFieldElimination) { then->AddSuccessor(join); else_->AddSuccessor(join); - then->AddInstruction( - new (&allocator) HInstanceFieldGet(parameter, Primitive::kPrimBoolean, - MemberOffset(42), false)); + then->AddInstruction(new (&allocator) HInstanceFieldGet(parameter, + Primitive::kPrimBoolean, + MemberOffset(42), + false, + kUnknownFieldIndex, + graph->GetDexFile())); then->AddInstruction(new (&allocator) HGoto()); - else_->AddInstruction( - new (&allocator) HInstanceFieldGet(parameter, Primitive::kPrimBoolean, - MemberOffset(42), false)); + else_->AddInstruction(new (&allocator) HInstanceFieldGet(parameter, + Primitive::kPrimBoolean, + MemberOffset(42), + false, + kUnknownFieldIndex, + graph->GetDexFile())); else_->AddInstruction(new (&allocator) HGoto()); - join->AddInstruction( - new (&allocator) HInstanceFieldGet(parameter, Primitive::kPrimBoolean, - MemberOffset(42), false)); + join->AddInstruction(new (&allocator) HInstanceFieldGet(parameter, + Primitive::kPrimBoolean, + MemberOffset(42), + false, + kUnknownFieldIndex, + graph->GetDexFile())); join->AddInstruction(new (&allocator) HExit()); graph->TryBuildingSsa(); @@ -144,9 +173,12 @@ TEST(GVNTest, LoopFieldElimination) { HBasicBlock* block = new (&allocator) HBasicBlock(graph); graph->AddBlock(block); entry->AddSuccessor(block); - block->AddInstruction( - new (&allocator) HInstanceFieldGet(parameter, Primitive::kPrimBoolean, - MemberOffset(42), false)); + block->AddInstruction(new (&allocator) HInstanceFieldGet(parameter, + Primitive::kPrimBoolean, + MemberOffset(42), + false, + kUnknownFieldIndex, + graph->GetDexFile())); block->AddInstruction(new (&allocator) HGoto()); HBasicBlock* loop_header = new (&allocator) HBasicBlock(graph); @@ -161,26 +193,40 @@ TEST(GVNTest, LoopFieldElimination) { loop_header->AddSuccessor(exit); loop_body->AddSuccessor(loop_header); - loop_header->AddInstruction( - new (&allocator) HInstanceFieldGet(parameter, Primitive::kPrimBoolean, - MemberOffset(42), false)); + loop_header->AddInstruction(new (&allocator) HInstanceFieldGet(parameter, + Primitive::kPrimBoolean, + MemberOffset(42), + false, + kUnknownFieldIndex, + graph->GetDexFile())); HInstruction* field_get_in_loop_header = loop_header->GetLastInstruction(); loop_header->AddInstruction(new (&allocator) HIf(block->GetLastInstruction())); // Kill inside the loop body to prevent field gets inside the loop header // and the body to be GVN'ed. - loop_body->AddInstruction(new (&allocator) HInstanceFieldSet( - parameter, parameter, Primitive::kPrimNot, MemberOffset(42), false)); + loop_body->AddInstruction(new (&allocator) HInstanceFieldSet(parameter, + parameter, + Primitive::kPrimNot, + MemberOffset(42), + false, + kUnknownFieldIndex, + graph->GetDexFile())); HInstruction* field_set = loop_body->GetLastInstruction(); - loop_body->AddInstruction( - new (&allocator) HInstanceFieldGet(parameter, Primitive::kPrimBoolean, - MemberOffset(42), false)); + loop_body->AddInstruction(new (&allocator) HInstanceFieldGet(parameter, + Primitive::kPrimBoolean, + MemberOffset(42), + false, + kUnknownFieldIndex, + graph->GetDexFile())); HInstruction* field_get_in_loop_body = loop_body->GetLastInstruction(); loop_body->AddInstruction(new (&allocator) HGoto()); - exit->AddInstruction( - new (&allocator) HInstanceFieldGet(parameter, Primitive::kPrimBoolean, - MemberOffset(42), false)); + exit->AddInstruction(new (&allocator) HInstanceFieldGet(parameter, + Primitive::kPrimBoolean, + MemberOffset(42), + false, + kUnknownFieldIndex, + graph->GetDexFile())); HInstruction* field_get_in_exit = exit->GetLastInstruction(); exit->AddInstruction(new (&allocator) HExit()); @@ -266,8 +312,13 @@ TEST(GVNTest, LoopSideEffects) { // Check that the loops don't have side effects. { // Make one block with a side effect. - entry->AddInstruction(new (&allocator) HInstanceFieldSet( - parameter, parameter, Primitive::kPrimNot, MemberOffset(42), false)); + entry->AddInstruction(new (&allocator) HInstanceFieldSet(parameter, + parameter, + Primitive::kPrimNot, + MemberOffset(42), + false, + kUnknownFieldIndex, + graph->GetDexFile())); SideEffectsAnalysis side_effects(graph); side_effects.Run(); @@ -280,8 +331,13 @@ TEST(GVNTest, LoopSideEffects) { // Check that the side effects of the outer loop does not affect the inner loop. { outer_loop_body->InsertInstructionBefore( - new (&allocator) HInstanceFieldSet( - parameter, parameter, Primitive::kPrimNot, MemberOffset(42), false), + new (&allocator) HInstanceFieldSet(parameter, + parameter, + Primitive::kPrimNot, + MemberOffset(42), + false, + kUnknownFieldIndex, + graph->GetDexFile()), outer_loop_body->GetLastInstruction()); SideEffectsAnalysis side_effects(graph); @@ -297,8 +353,13 @@ TEST(GVNTest, LoopSideEffects) { { outer_loop_body->RemoveInstruction(outer_loop_body->GetFirstInstruction()); inner_loop_body->InsertInstructionBefore( - new (&allocator) HInstanceFieldSet( - parameter, parameter, Primitive::kPrimNot, MemberOffset(42), false), + new (&allocator) HInstanceFieldSet(parameter, + parameter, + Primitive::kPrimNot, + MemberOffset(42), + false, + kUnknownFieldIndex, + graph->GetDexFile()), inner_loop_body->GetLastInstruction()); SideEffectsAnalysis side_effects(graph); -- cgit v1.2.3-59-g8ed1b