Check invocation's side effects for LSE.
More optimization is allowed if an invocation doesn't do read/write.
Test: run-test on host.
Change-Id: Id80e2fa90b8c843afd852778e8f7e6c69c765ad5
diff --git a/compiler/optimizing/escape.cc b/compiler/optimizing/escape.cc
index 9df5bf1..88e9326 100644
--- a/compiler/optimizing/escape.cc
+++ b/compiler/optimizing/escape.cc
@@ -51,7 +51,9 @@
*is_singleton_and_not_returned = false;
*is_singleton_and_not_deopt_visible = false;
return;
- } else if (user->IsPhi() || user->IsSelect() || user->IsInvoke() ||
+ } else if (user->IsPhi() ||
+ user->IsSelect() ||
+ (user->IsInvoke() && user->GetSideEffects().DoesAnyWrite()) ||
(user->IsInstanceFieldSet() && (reference == user->InputAt(1))) ||
(user->IsUnresolvedInstanceFieldSet() && (reference == user->InputAt(1))) ||
(user->IsStaticFieldSet() && (reference == user->InputAt(1))) ||
diff --git a/compiler/optimizing/load_store_elimination.cc b/compiler/optimizing/load_store_elimination.cc
index 7dff696..c041f56 100644
--- a/compiler/optimizing/load_store_elimination.cc
+++ b/compiler/optimizing/load_store_elimination.cc
@@ -528,15 +528,21 @@
}
}
- void HandleInvoke(HInstruction* invoke) {
+ void HandleInvoke(HInstruction* instruction) {
+ SideEffects side_effects = instruction->GetSideEffects();
ScopedArenaVector<HInstruction*>& heap_values =
- heap_values_for_[invoke->GetBlock()->GetBlockId()];
+ heap_values_for_[instruction->GetBlock()->GetBlockId()];
for (size_t i = 0; i < heap_values.size(); i++) {
ReferenceInfo* ref_info = heap_location_collector_.GetHeapLocation(i)->GetReferenceInfo();
if (ref_info->IsSingleton()) {
// Singleton references cannot be seen by the callee.
} else {
- heap_values[i] = kUnknownHeapValue;
+ if (side_effects.DoesAnyRead()) {
+ KeepIfIsStore(heap_values[i]);
+ }
+ if (side_effects.DoesAnyWrite()) {
+ heap_values[i] = kUnknownHeapValue;
+ }
}
}
}