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
diff --git a/compiler/optimizing/gvn_test.cc b/compiler/optimizing/gvn_test.cc
index c3ce7e1..d8a09ff 100644
--- a/compiler/optimizing/gvn_test.cc
+++ b/compiler/optimizing/gvn_test.cc
@@ -40,23 +40,40 @@
   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 @@
   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 @@
   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 @@
   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 @@
   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 @@
   // 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 @@
   // 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 @@
   {
     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);