summaryrefslogtreecommitdiff
path: root/compiler/optimizing
diff options
context:
space:
mode:
author Nicolas Geoffray <ngeoffray@google.com> 2016-03-17 14:20:58 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2016-03-17 14:20:59 +0000
commit07c4134a759500383bf5931fe12941f48fd051da (patch)
tree2a9ffbf2cb65aa28e8ec5d298f97d81c16d2408f /compiler/optimizing
parent0205b58a0d7a9ce5832393857c19c086c78996e9 (diff)
parent0397163516fb882589c5be734439dedfe4d271fb (diff)
Merge "Fix load store elimination bug in the presence of null[i]."
Diffstat (limited to 'compiler/optimizing')
-rw-r--r--compiler/optimizing/code_generator_x86.cc1
-rw-r--r--compiler/optimizing/load_store_elimination.cc17
2 files changed, 18 insertions, 0 deletions
diff --git a/compiler/optimizing/code_generator_x86.cc b/compiler/optimizing/code_generator_x86.cc
index 9acaa1d000..3b643a3c4f 100644
--- a/compiler/optimizing/code_generator_x86.cc
+++ b/compiler/optimizing/code_generator_x86.cc
@@ -4796,6 +4796,7 @@ void InstructionCodeGeneratorX86::HandleFieldSet(HInstruction* instruction,
int32_t v = CodeGenerator::GetInt32ValueOf(value.GetConstant());
__ movl(Address(base, offset), Immediate(v));
} else {
+ DCHECK(value.IsRegister()) << value;
__ movl(Address(base, offset), value.AsRegister<Register>());
}
break;
diff --git a/compiler/optimizing/load_store_elimination.cc b/compiler/optimizing/load_store_elimination.cc
index 8eaac0bbd3..561dcfbb1f 100644
--- a/compiler/optimizing/load_store_elimination.cc
+++ b/compiler/optimizing/load_store_elimination.cc
@@ -728,6 +728,23 @@ class LSEVisitor : public HGraphVisitor {
// This acts like GVN but with better aliasing analysis.
heap_values[idx] = instruction;
} else {
+ if (Primitive::PrimitiveKind(heap_value->GetType())
+ != Primitive::PrimitiveKind(instruction->GetType())) {
+ // The only situation where the same heap location has different type is when
+ // we do an array get from a null constant. In order to stay properly typed
+ // we do not merge the array gets.
+ if (kIsDebugBuild) {
+ DCHECK(heap_value->IsArrayGet()) << heap_value->DebugName();
+ DCHECK(instruction->IsArrayGet()) << instruction->DebugName();
+ HInstruction* array = instruction->AsArrayGet()->GetArray();
+ DCHECK(array->IsNullCheck()) << array->DebugName();
+ DCHECK(array->InputAt(0)->IsNullConstant()) << array->InputAt(0)->DebugName();
+ array = heap_value->AsArrayGet()->GetArray();
+ DCHECK(array->IsNullCheck()) << array->DebugName();
+ DCHECK(array->InputAt(0)->IsNullConstant()) << array->InputAt(0)->DebugName();
+ }
+ return;
+ }
removed_loads_.push_back(instruction);
substitute_instructions_for_loads_.push_back(heap_value);
TryRemovingNullCheck(instruction);