Changes to LLVM to support deoptimization.
Added a magic exception value (-1) and a handler to transition
to the interpreter. This is currently untested.
Change-Id: I2f53135e7505c54355ecf7c579897f68bbdcbda3
diff --git a/src/compiler_llvm/gbc_expander.cc b/src/compiler_llvm/gbc_expander.cc
index cc3c3f9..f5d6e8c 100644
--- a/src/compiler_llvm/gbc_expander.cc
+++ b/src/compiler_llvm/gbc_expander.cc
@@ -780,7 +780,19 @@
EmitUpdateDexPC(dex_pc);
}
irb_.Runtime().EmitTestSuspend();
- irb_.CreateBr(basic_block_cont);
+
+ llvm::BasicBlock* basic_block_exception = CreateBasicBlockWithDexPC(dex_pc, "exception");
+ llvm::Value* exception_pending = irb_.Runtime().EmitIsExceptionPending();
+ irb_.CreateCondBr(exception_pending, basic_block_exception, basic_block_cont, kUnlikely);
+
+ irb_.SetInsertPoint(basic_block_exception);
+ llvm::Type* ret_type = call_inst.getParent()->getParent()->getReturnType();
+ if (ret_type->isVoidTy()) {
+ irb_.CreateRetVoid();
+ } else {
+ // The return value is ignored when there's an exception.
+ irb_.CreateRet(llvm::UndefValue::get(ret_type));
+ }
irb_.SetInsertPoint(basic_block_cont);
return;