Revert "Revert "Revert "Use the object class as top in reference type propagation"""
This reverts commit 80caa1478cf3df4eac1214d8a63a4da6f4fe622b.
Change-Id: I63b51ca418b19b2bfb5ede3f8444f8fbeb8a339d
diff --git a/compiler/optimizing/instruction_simplifier.cc b/compiler/optimizing/instruction_simplifier.cc
index 1089812..b30b6c7 100644
--- a/compiler/optimizing/instruction_simplifier.cc
+++ b/compiler/optimizing/instruction_simplifier.cc
@@ -195,16 +195,16 @@
// Returns whether doing a type test between the class of `object` against `klass` has
// a statically known outcome. The result of the test is stored in `outcome`.
static bool TypeCheckHasKnownOutcome(HLoadClass* klass, HInstruction* object, bool* outcome) {
- ReferenceTypeInfo obj_rti = object->GetReferenceTypeInfo();
- ScopedObjectAccess soa(Thread::Current());
- if (!obj_rti.IsValid()) {
- // We run the simplifier before the reference type propagation so type info might not be
- // available.
+ if (!klass->IsResolved()) {
+ // If the class couldn't be resolve it's not safe to compare against it. It's
+ // default type would be Top which might be wider that the actual class type
+ // and thus producing wrong results.
return false;
}
+ ReferenceTypeInfo obj_rti = object->GetReferenceTypeInfo();
ReferenceTypeInfo class_rti = klass->GetLoadedClassRTI();
- DCHECK(class_rti.IsValid() && class_rti.IsExact());
+ ScopedObjectAccess soa(Thread::Current());
if (class_rti.IsSupertypeOf(obj_rti)) {
*outcome = true;
return true;