diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2010-05-28 17:34:43 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2010-05-28 17:34:43 +0000 |
commit | 3336de141a6455939a7d1ac46cf4cb088ca3f80b (patch) | |
tree | 55d298bb925546f672e677bab252bfada61707fc /clang/lib/CodeGen | |
parent | aabfdb39affc822cd6afd46cb3f5e6e341137f51 (diff) | |
download | bcm5719-llvm-3336de141a6455939a7d1ac46cf4cb088ca3f80b.tar.gz bcm5719-llvm-3336de141a6455939a7d1ac46cf4cb088ca3f80b.zip |
zero-cost exception API for NeXt runtime.
rethrow inside @catch block must use objc_exception_rethrow
API. Fixes radar 8037512. Test will be added to LLVM
test suite.
llvm-svn: 104964
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CGObjCMac.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp index d3bafd7eda7..94735b08718 100644 --- a/clang/lib/CodeGen/CGObjCMac.cpp +++ b/clang/lib/CodeGen/CGObjCMac.cpp @@ -440,6 +440,15 @@ public: return CGM.CreateRuntimeFunction(FTy, "objc_exception_throw"); } + /// ExceptionRethrowFn - LLVM objc_exception_rethrow function. + llvm::Constant *getExceptionRethrowFn() { + // void objc_exception_rethrow(void) + std::vector<const llvm::Type*> Args; + llvm::FunctionType *FTy = + llvm::FunctionType::get(llvm::Type::getVoidTy(VMContext), Args, true); + return CGM.CreateRuntimeFunction(FTy, "objc_exception_rethrow"); + } + /// SyncEnterFn - LLVM object_sync_enter function. llvm::Constant *getSyncEnterFn() { // void objc_sync_enter (id) @@ -5803,12 +5812,15 @@ CGObjCNonFragileABIMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, void CGObjCNonFragileABIMac::EmitThrowStmt(CodeGen::CodeGenFunction &CGF, const ObjCAtThrowStmt &S) { llvm::Value *Exception; + llvm::Constant *FunctionThrowOrRethrow; if (const Expr *ThrowExpr = S.getThrowExpr()) { Exception = CGF.EmitScalarExpr(ThrowExpr); + FunctionThrowOrRethrow = ObjCTypes.getExceptionThrowFn(); } else { assert((!CGF.ObjCEHValueStack.empty() && CGF.ObjCEHValueStack.back()) && "Unexpected rethrow outside @catch block."); Exception = CGF.ObjCEHValueStack.back(); + FunctionThrowOrRethrow = ObjCTypes.getExceptionRethrowFn(); } llvm::Value *ExceptionAsObject = @@ -5816,12 +5828,12 @@ void CGObjCNonFragileABIMac::EmitThrowStmt(CodeGen::CodeGenFunction &CGF, llvm::BasicBlock *InvokeDest = CGF.getInvokeDest(); if (InvokeDest) { llvm::BasicBlock *Cont = CGF.createBasicBlock("invoke.cont"); - CGF.Builder.CreateInvoke(ObjCTypes.getExceptionThrowFn(), + CGF.Builder.CreateInvoke(FunctionThrowOrRethrow, Cont, InvokeDest, &ExceptionAsObject, &ExceptionAsObject + 1); CGF.EmitBlock(Cont); } else - CGF.Builder.CreateCall(ObjCTypes.getExceptionThrowFn(), ExceptionAsObject); + CGF.Builder.CreateCall(FunctionThrowOrRethrow, ExceptionAsObject); CGF.Builder.CreateUnreachable(); // Clear the insertion point to indicate we are in unreachable code. |