[llvm-branch-commits] [cfe-branch] r105049 - /cfe/branches/Apple/whitney/lib/CodeGen/CGObjCMac.cpp

Daniel Dunbar daniel at zuster.org
Fri May 28 16:07:19 PDT 2010


Author: ddunbar
Date: Fri May 28 18:07:19 2010
New Revision: 105049

URL: http://llvm.org/viewvc/llvm-project?rev=105049&view=rev
Log:
Merge r104964:
--
Author: Fariborz Jahanian <fjahanian at apple.com>
Date:   Fri May 28 17:34:43 2010 +0000

    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.

Modified:
    cfe/branches/Apple/whitney/lib/CodeGen/CGObjCMac.cpp

Modified: cfe/branches/Apple/whitney/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/CodeGen/CGObjCMac.cpp?rev=105049&r1=105048&r2=105049&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/branches/Apple/whitney/lib/CodeGen/CGObjCMac.cpp Fri May 28 18:07:19 2010
@@ -440,6 +440,15 @@
     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 @@
 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 @@
   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.





More information about the llvm-branch-commits mailing list