From ecf52dfa46addbbd5d1ee92a4bc9b7a9fd960629 Mon Sep 17 00:00:00 2001 From: David Brazdil Date: Mon, 14 Dec 2015 16:58:08 +0000 Subject: ART: Fix bug in LSE LSE will not remove a load if the type of the heap value does not match the type of the load. This was a workaround for b/22538329 but backfires for integers. For example, 'IntConstant 0' has type int but can be retrieved from a boolean field. The corresponding store is removed but not the load, loading uninitialized memory. This fixes the issue until the workaround is not needed any more. Change-Id: I2a47783e8d5f93104854e5216b69b6c220832c76 --- compiler/optimizing/load_store_elimination.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'compiler/optimizing') diff --git a/compiler/optimizing/load_store_elimination.cc b/compiler/optimizing/load_store_elimination.cc index adde00464b..2a2221a82c 100644 --- a/compiler/optimizing/load_store_elimination.cc +++ b/compiler/optimizing/load_store_elimination.cc @@ -655,6 +655,16 @@ class LSEVisitor : public HGraphVisitor { } } + static bool IsIntFloatAlias(Primitive::Type type1, Primitive::Type type2) { + return (type1 == Primitive::kPrimFloat && type2 == Primitive::kPrimInt) || + (type2 == Primitive::kPrimFloat && type1 == Primitive::kPrimInt); + } + + static bool IsLongDoubleAlias(Primitive::Type type1, Primitive::Type type2) { + return (type1 == Primitive::kPrimDouble && type2 == Primitive::kPrimLong) || + (type2 == Primitive::kPrimDouble && type1 == Primitive::kPrimLong); + } + void VisitGetLocation(HInstruction* instruction, HInstruction* ref, size_t offset, @@ -686,7 +696,8 @@ class LSEVisitor : public HGraphVisitor { if ((heap_value != kUnknownHeapValue) && // Keep the load due to possible I/F, J/D array aliasing. // See b/22538329 for details. - (heap_value->GetType() == instruction->GetType())) { + !IsIntFloatAlias(heap_value->GetType(), instruction->GetType()) && + !IsLongDoubleAlias(heap_value->GetType(), instruction->GetType())) { removed_loads_.push_back(instruction); substitute_instructions_for_loads_.push_back(heap_value); TryRemovingNullCheck(instruction); -- cgit v1.2.3-59-g8ed1b