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/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;
+ }
}
}
}