diff options
| author | 2012-07-26 14:01:13 -0700 | |
|---|---|---|
| committer | 2012-07-26 14:01:13 -0700 | |
| commit | 9a2487f94efeb88016a695af823bf26799ef0f06 (patch) | |
| tree | 19525acc9c56763a35a12afc2e900fa346c3444d /src/compiler/codegen/MethodBitcode.cc | |
| parent | 854029c13351fd3a8f7794eb6c2c73af0fde8ac8 (diff) | |
Quick compiler - NOT_LONG and verification fixes
We continue to have issues when the verifier rewrites Dalvik
byte codes. This is a workaround to fix the GBC -> LIR
conversion, but I suspect I'm going to have to add a dead code
elimination pass to get things working properly for llvm. The
basic problem is that if the re-written instruction defined a
Dalvik virtual register, then we lose the definition. The
MIR to GBC converter doesn't handle uses without definitions
very well.
Change-Id: Ia235c299b686ce080755f9bb4c05c719c16c0d77
Diffstat (limited to 'src/compiler/codegen/MethodBitcode.cc')
| -rw-r--r-- | src/compiler/codegen/MethodBitcode.cc | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/src/compiler/codegen/MethodBitcode.cc b/src/compiler/codegen/MethodBitcode.cc index 3ec4a1100e..79501a40a0 100644 --- a/src/compiler/codegen/MethodBitcode.cc +++ b/src/compiler/codegen/MethodBitcode.cc @@ -49,7 +49,11 @@ llvm::Value* getLLVMValue(CompilationUnit* cUnit, int sReg) void defineValue(CompilationUnit* cUnit, llvm::Value* val, int sReg) { llvm::Value* placeholder = getLLVMValue(cUnit, sReg); - CHECK(placeholder != NULL) << "Null placeholder - shouldn't happen"; + if (placeholder == NULL) { + // This can happen on instruction rewrite on verification failure + LOG(WARNING) << "Null placeholder - invalid CFG"; + return; + } placeholder->replaceAllUsesWith(val); val->takeName(placeholder); cUnit->llvmValues.elemList[sReg] = (intptr_t)val; @@ -1299,7 +1303,13 @@ bool convertMIRNode(CompilationUnit* cUnit, MIR* mir, BasicBlock* bb, case Instruction::MOVE_RESULT: case Instruction::MOVE_RESULT_OBJECT: #if defined(TARGET_ARM) - CHECK(false) << "Unexpected MOVE_RESULT"; + /* + * Instruction rewriting on verification failure can eliminate + * the invoke that feeds this move0result. It won't ever be reached, + * so we can ignore it. + * TODO: verify that previous instruction if THROW_VERIFICATION_ERROR + */ + UNIMPLEMENTED(WARNING) << "Need to verify previous inst was rewritten"; #else UNIMPLEMENTED(WARNING) << "need x86 move-result fusing"; #endif @@ -2262,12 +2272,19 @@ void cvtBinOp(CompilationUnit* cUnit, OpKind op, llvm::Instruction* inst) DCHECK(lhsImm == NULL); RegLocation rlSrc1 = getLoc(cUnit, inst->getOperand(0)); llvm::Value* rhs = inst->getOperand(1); - if (llvm::ConstantInt* src2 = llvm::dyn_cast<llvm::ConstantInt>(rhs)) { + llvm::ConstantInt* constRhs = llvm::dyn_cast<llvm::ConstantInt>(rhs); + if (!rlDest.wide && (constRhs != NULL)) { Instruction::Code dalvikOp = getDalvikOpcode(op, true, false); - genArithOpIntLit(cUnit, dalvikOp, rlDest, rlSrc1, src2->getSExtValue()); + genArithOpIntLit(cUnit, dalvikOp, rlDest, rlSrc1, constRhs->getSExtValue()); } else { Instruction::Code dalvikOp = getDalvikOpcode(op, false, rlDest.wide); - RegLocation rlSrc2 = getLoc(cUnit, rhs); + RegLocation rlSrc2; + if (constRhs != NULL) { + DCHECK_EQ(dalvikOp, Instruction::NOT_LONG); + rlSrc2 = rlSrc1; + } else { + rlSrc2 = getLoc(cUnit, rhs); + } if (rlDest.wide) { genArithOpLong(cUnit, dalvikOp, rlDest, rlSrc1, rlSrc2); } else { |