Real fix for 064
The recent ssa cleanup CL surfaced a somewhat subtle bug in
live register tracking. The code generation register utilities
attempt to remember and reuse live Dalvik register values for future
use. This remembering takes place in the storeValueXX() code.
For this to work, though, storeValue may only be called once during
the compilation of any single Dalvik instruction.
However, the code generation routine for CONST_CLASS included a
somewhat complicated slow path with iternal branches and two
generated "storeValue" locations. This resulted in downstream
code expecting to find a live value in the wrong place.
This fix is to note this special case and do a "clobber" on the ssa name.
This CL also includes some sanity checking code that can detect
multiple calls to storeValue during one intruction compilation to
try to catch this situation in the future.
Change-Id: I66a279140accd80cda83f66efe570c9702fb351b
diff --git a/src/compiler/SSATransformation.cc b/src/compiler/SSATransformation.cc
index bd5f83b..c5a6b8f 100644
--- a/src/compiler/SSATransformation.cc
+++ b/src/compiler/SSATransformation.cc
@@ -26,14 +26,22 @@
if (block->visited || block->hidden) return;
block->visited = true;
+ // Can this block be reached only via previous block fallthrough?
+ if ((block->blockType == kDalvikByteCode) &&
+ (block->predecessors->numUsed == 1)) {
+ DCHECK_GE(cUnit->dfsOrder.numUsed, 1U);
+ int prevIdx = cUnit->dfsOrder.numUsed - 1;
+ int prevId = cUnit->dfsOrder.elemList[prevIdx];
+ BasicBlock* predBB = (BasicBlock*)block->predecessors->elemList[0];
+ if (predBB->id == prevId) {
+ block->fallThroughTarget = true;
+ }
+ }
+
/* Enqueue the preOrder block id */
oatInsertGrowableList(cUnit, &cUnit->dfsOrder, block->id);
if (block->fallThrough) {
-#if 0
- // Temporary bug workaround
- block->fallThrough->fallThroughTarget = true;
-#endif
recordDFSOrders(cUnit, block->fallThrough);
}
if (block->taken) recordDFSOrders(cUnit, block->taken);