Set more RTI only if they are valid
Follow-up to aosp/2442280. We haven't seen crashes with these ones,
but we can't guarantee that the RTI will be valid in these code paths.
Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b
Change-Id: I80da85a6549ba0275a80027016363e0cf9fb8045
diff --git a/compiler/optimizing/dead_code_elimination.cc b/compiler/optimizing/dead_code_elimination.cc
index 5437d9b..cf49e39 100644
--- a/compiler/optimizing/dead_code_elimination.cc
+++ b/compiler/optimizing/dead_code_elimination.cc
@@ -181,6 +181,13 @@
} else if (!cond->InputAt(0)->IsNullConstant()) {
return false;
}
+
+ // We can't create a BoundType for an object with an invalid RTI.
+ const ReferenceTypeInfo ti = obj->GetReferenceTypeInfo();
+ if (!ti.IsValid()) {
+ return false;
+ }
+
// Scan all uses of obj and find null check under control dependence.
HBoundType* bound = nullptr;
const HUseList<HInstruction*>& uses = obj->GetUses();
@@ -193,7 +200,6 @@
user_block != throws &&
block->Dominates(user_block)) {
if (bound == nullptr) {
- ReferenceTypeInfo ti = obj->GetReferenceTypeInfo();
bound = new (obj->GetBlock()->GetGraph()->GetAllocator()) HBoundType(obj);
bound->SetUpperBound(ti, /*can_be_null*/ false);
bound->SetReferenceTypeInfo(ti);