Workaround for cfg building failure
Currently the compiler expects well-formed control flow graphs -
no dead code (though infinate loops are allowed). This is the
case for all dx output (but might not be for custom tools).
However, when the verifier replaces an instruction with
OP_THROW_VERIFICATION_ERROR, it can create dead code from a
previously well-formed graph. This CL works around that
problem by not treating OP_THROW_VERIFICATION_ERROR as a
direct branch.
A future CL will alter the CFG builder to be resiliant in the face
of dead code.
Also, removes a spurious DCHECK, and adds a few where they are
needed.
Change-Id: I68554a2a8b88e857faeff3300f2ebbf2d0323693
diff --git a/src/compiler/Frontend.cc b/src/compiler/Frontend.cc
index a0e7713..f8f985d 100644
--- a/src/compiler/Frontend.cc
+++ b/src/compiler/Frontend.cc
@@ -675,11 +675,13 @@
/* create */
true);
/*
- * OP_THROW and OP_THROW_VERIFICATION_ERROR are unconditional
- * branches.
+ * OP_THROW is an unconditional branch. NOTE:
+ * OP_THROW_VERIFICATION_ERROR is also an unconditional
+ * branch, but we shouldn't treat it as such until we have
+ * a dead code elimination pass (which won't be important
+ * until inlining w/ constant propogation is implemented.
*/
- if (insn->dalvikInsn.opcode != OP_THROW_VERIFICATION_ERROR &&
- insn->dalvikInsn.opcode != OP_THROW) {
+ if (insn->dalvikInsn.opcode != OP_THROW) {
curBlock->fallThrough = fallthroughBlock;
oatSetBit(fallthroughBlock->predecessors, curBlock->id);
}
diff --git a/src/compiler/codegen/arm/MethodCodegenDriver.cc b/src/compiler/codegen/arm/MethodCodegenDriver.cc
index 366a6d3..7ea7d69 100644
--- a/src/compiler/codegen/arm/MethodCodegenDriver.cc
+++ b/src/compiler/codegen/arm/MethodCodegenDriver.cc
@@ -483,7 +483,6 @@
DecodedInstruction* dInsn, int state,
ArmLIR* rollback)
{
- DCHECK(rollback == NULL);
RegLocation rlArg;
ArmLIR* skipBranch;
ArmLIR* skipTarget;
@@ -583,6 +582,7 @@
DecodedInstruction* dInsn, int state,
ArmLIR* rollback)
{
+ DCHECK(rollback == NULL);
switch(state) {
case 0: // Load trampoline target
loadWordDisp(cUnit, rSELF,
@@ -659,7 +659,6 @@
DecodedInstruction* dInsn, int state,
ArmLIR* rollback)
{
- DCHECK(rollback == NULL);
RegLocation rlArg;
ArmLIR* skipBranch;
ArmLIR* skipTarget;