Bonus changes:
* Add a undefined Thumb instruction between the last code block and the
beginning of PC reconstruction cell to capture such codegen problem on
the spot.
* Fix a loop formation problem to exclude nested loops.
Bug:
4320840
Change-Id: I49d3fbba0073d8c2d4a0b241258239cb952c6bdd
}
/* Handle the fallthrough path */
+ bottomBlock->needFallThroughBranch = origBlock->needFallThroughBranch;
bottomBlock->fallThrough = origBlock->fallThrough;
origBlock->fallThrough = bottomBlock;
origBlock->needFallThroughBranch = true;
*/
while (true) {
/* Loop formed */
- if (bodyBB->taken == firstBB || bodyBB->fallThrough == firstBB) break;
+ if (bodyBB->taken == firstBB) {
+ /* Check if the fallThrough edge will cause a nested loop */
+ if (bodyBB->fallThrough &&
+ dvmIsBitSet(cUnit->tempBlockV, bodyBB->fallThrough->id)) {
+ return false;
+ }
+ /* Single loop formed */
+ break;
+ } else if (bodyBB->fallThrough == firstBB) {
+ /* Check if the taken edge will cause a nested loop */
+ if (bodyBB->taken &&
+ dvmIsBitSet(cUnit->tempBlockV, bodyBB->taken->id)) {
+ return false;
+ }
+ /* Single loop formed */
+ break;
+ }
/* Inner loops formed first - quit */
if (bodyBB->fallThrough &&
kThumb2Dmb, /* dmb [1111001110111111100011110101] option[3-0] */
kThumb2LdrPcReln12, /* ldr rd,[pc,-#imm12] [1111100011011111] rt[15-12]
imm12[11-0] */
-
+ kThumbUndefined, /* undefined [11011110xxxxxxxx] */
kArmLast,
} ArmOpcode;
kFmtUnused, -1, -1,
IS_BINARY_OP | REG_DEF0 | REG_USE_PC | IS_LOAD,
"ldr", "r!0d, [r15pc, -#!1d]", 2),
+ ENCODING_MAP(kThumbUndefined, 0xde00,
+ kFmtUnused, -1, -1, kFmtUnused, -1, -1, kFmtUnused, -1, -1,
+ kFmtUnused, -1, -1, NO_OPERAND,
+ "undefined", "", 1),
};
/*
(ArmLIR **) cUnit->pcReconstructionList.elemList;
int numElems = cUnit->pcReconstructionList.numUsed;
int i;
+
+ /*
+ * We should never reach here through fall-through code, so insert
+ * a bomb to signal troubles immediately.
+ */
+ if (numElems) {
+ newLIR0(cUnit, kThumbUndefined);
+ }
+
for (i = 0; i < numElems; i++) {
dvmCompilerAppendLIR(cUnit, (LIR *) pcrLabel[i]);
/* r0 = dalvik PC */