Don't mark objc_retainBlock as nounwind. It calls user copy constructors
authorDan Gohman <gohman@apple.com>
Wed, 14 Sep 2011 18:33:34 +0000 (18:33 +0000)
committerDan Gohman <gohman@apple.com>
Wed, 14 Sep 2011 18:33:34 +0000 (18:33 +0000)
which could theoretically throw.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139710 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/ObjCARC.cpp

index f978f571c6c54a9395ee9c3ca4fce3edcc290d1b..f7e0cd4fe14e8ead1972e5ae8a20b0c2dd4eed94 100644 (file)
@@ -425,9 +425,10 @@ static bool IsAlwaysTail(InstructionClass Class) {
 /// IsNoThrow - Test if the given class represents instructions which are always
 /// safe to mark with the nounwind attribute..
 static bool IsNoThrow(InstructionClass Class) {
+  // objc_retainBlock is not nounwind because it calls user copy constructors
+  // which could theoretically throw.
   return Class == IC_Retain ||
          Class == IC_RetainRV ||
-         Class == IC_RetainBlock ||
          Class == IC_Release ||
          Class == IC_Autorelease ||
          Class == IC_AutoreleaseRV ||
@@ -1605,7 +1606,8 @@ Constant *ObjCARCOpt::getRetainBlockCallee(Module *M) {
     std::vector<Type *> Params;
     Params.push_back(PointerType::getUnqual(Type::getInt8Ty(C)));
     AttrListPtr Attributes;
-    Attributes.addAttr(~0u, Attribute::NoUnwind);
+    // objc_retainBlock is not nounwind because it calls user copy constructors
+    // which could theoretically throw.
     RetainBlockCallee =
       M->getOrInsertFunction(
         "objc_retainBlock",