GVN final fields even with side effects.
Two accesses of a final field can be GVN'ed even if there are
side effects between them.
Change-Id: I04495ae83c7858f4216b083ad1c29851954320ad
diff --git a/compiler/optimizing/builder.cc b/compiler/optimizing/builder.cc
index 0f44af0..c04fe4e 100644
--- a/compiler/optimizing/builder.cc
+++ b/compiler/optimizing/builder.cc
@@ -816,6 +816,7 @@
current_block_->GetLastInstruction(),
field_type,
resolved_field->GetOffset(),
+ resolved_field->IsFinal(),
resolved_field->IsVolatile()));
UpdateLocal(source_or_dest_reg, current_block_->GetLastInstruction());
@@ -917,13 +918,19 @@
temps.Add(cls);
HInstruction* value = LoadLocal(source_or_dest_reg, field_type);
DCHECK_EQ(value->GetType(), field_type);
- current_block_->AddInstruction(
- new (arena_) HStaticFieldSet(cls, value, field_type, resolved_field->GetOffset(),
- resolved_field->IsVolatile()));
+ current_block_->AddInstruction(new (arena_) HStaticFieldSet(
+ cls,
+ value,
+ field_type,
+ resolved_field->GetOffset(),
+ resolved_field->IsVolatile()));
} else {
- current_block_->AddInstruction(
- new (arena_) HStaticFieldGet(cls, field_type, resolved_field->GetOffset(),
- resolved_field->IsVolatile()));
+ current_block_->AddInstruction(new (arena_) HStaticFieldGet(
+ cls,
+ field_type,
+ resolved_field->GetOffset(),
+ resolved_field->IsFinal(),
+ resolved_field->IsVolatile()));
UpdateLocal(source_or_dest_reg, current_block_->GetLastInstruction());
}
return true;