Improve tracking of memory locations in LVN.
Rewrite the tracking of values stored in memory to allow
recognizing the same value after storing it in memory and
loading it back to vreg. Drop reliance on value name
ordering for memory versioning in preparation for GVN.
Also fix a few minor issues in LVN.
Change-Id: Ifabe2d47d669d9ec43942cea6fd157e41af77ec8
diff --git a/compiler/dex/mir_optimization.cc b/compiler/dex/mir_optimization.cc
index 1d4aef2..256686e 100644
--- a/compiler/dex/mir_optimization.cc
+++ b/compiler/dex/mir_optimization.cc
@@ -320,9 +320,11 @@
return true;
}
bool use_lvn = bb->use_lvn;
+ std::unique_ptr<ScopedArenaAllocator> allocator;
std::unique_ptr<LocalValueNumbering> local_valnum;
if (use_lvn) {
- local_valnum.reset(LocalValueNumbering::Create(cu_));
+ allocator.reset(ScopedArenaAllocator::Create(&cu_->arena_stack));
+ local_valnum.reset(new (allocator.get()) LocalValueNumbering(cu_, allocator.get()));
}
while (bb != NULL) {
for (MIR* mir = bb->first_mir_insn; mir != NULL; mir = mir->next) {
@@ -550,6 +552,9 @@
}
bb = ((cu_->disable_opt & (1 << kSuppressExceptionEdges)) != 0) ? NextDominatedBlock(bb) : NULL;
}
+ if (use_lvn && UNLIKELY(!local_valnum->Good())) {
+ LOG(WARNING) << "LVN overflow in " << PrettyMethod(cu_->method_idx, *cu_->dex_file);
+ }
return true;
}