Add an enum for the return and function indexes into the AttrListPtr object. This...
[oota-llvm.git] / lib / Transforms / Scalar / ObjCARC.cpp
index dca6a72fb16b712b0e3ebbcfa843504f7b1ba544..017df8f1a4db7f7d109e4679bf2031eecafcfd78 100644 (file)
@@ -1789,8 +1789,10 @@ Constant *ObjCARCOpt::getRetainRVCallee(Module *M) {
     Type *Params[] = { I8X };
     FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false);
     Attributes::Builder B;
-    B.addNoUnwindAttr();
-    AttrListPtr Attributes = AttrListPtr().addAttr(~0u, Attributes::get(B));
+    B.addAttribute(Attributes::NoUnwind);
+    AttrListPtr Attributes =
+      AttrListPtr().addAttr(M->getContext(), AttrListPtr::FunctionIndex,
+                            Attributes::get(M->getContext(), B));
     RetainRVCallee =
       M->getOrInsertFunction("objc_retainAutoreleasedReturnValue", FTy,
                              Attributes);
@@ -1805,8 +1807,10 @@ Constant *ObjCARCOpt::getAutoreleaseRVCallee(Module *M) {
     Type *Params[] = { I8X };
     FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false);
     Attributes::Builder B;
-    B.addNoUnwindAttr();
-    AttrListPtr Attributes = AttrListPtr().addAttr(~0u, Attributes::get(B));
+    B.addAttribute(Attributes::NoUnwind);
+    AttrListPtr Attributes =
+      AttrListPtr().addAttr(M->getContext(), AttrListPtr::FunctionIndex,
+                            Attributes::get(C, B));
     AutoreleaseRVCallee =
       M->getOrInsertFunction("objc_autoreleaseReturnValue", FTy,
                              Attributes);
@@ -1819,8 +1823,10 @@ Constant *ObjCARCOpt::getReleaseCallee(Module *M) {
     LLVMContext &C = M->getContext();
     Type *Params[] = { PointerType::getUnqual(Type::getInt8Ty(C)) };
     Attributes::Builder B;
-    B.addNoUnwindAttr();
-    AttrListPtr Attributes = AttrListPtr().addAttr(~0u, Attributes::get(B));
+    B.addAttribute(Attributes::NoUnwind);
+    AttrListPtr Attributes =
+      AttrListPtr().addAttr(M->getContext(), AttrListPtr::FunctionIndex,
+                            Attributes::get(C, B));
     ReleaseCallee =
       M->getOrInsertFunction(
         "objc_release",
@@ -1835,8 +1841,10 @@ Constant *ObjCARCOpt::getRetainCallee(Module *M) {
     LLVMContext &C = M->getContext();
     Type *Params[] = { PointerType::getUnqual(Type::getInt8Ty(C)) };
     Attributes::Builder B;
-    B.addNoUnwindAttr();
-    AttrListPtr Attributes = AttrListPtr().addAttr(~0u, Attributes::get(B));
+    B.addAttribute(Attributes::NoUnwind);
+    AttrListPtr Attributes =
+      AttrListPtr().addAttr(M->getContext(), AttrListPtr::FunctionIndex,
+                            Attributes::get(C, B));
     RetainCallee =
       M->getOrInsertFunction(
         "objc_retain",
@@ -1866,8 +1874,10 @@ Constant *ObjCARCOpt::getAutoreleaseCallee(Module *M) {
     LLVMContext &C = M->getContext();
     Type *Params[] = { PointerType::getUnqual(Type::getInt8Ty(C)) };
     Attributes::Builder B;
-    B.addNoUnwindAttr();
-    AttrListPtr Attributes = AttrListPtr().addAttr(~0u, Attributes::get(B));
+    B.addAttribute(Attributes::NoUnwind);
+    AttrListPtr Attributes =
+      AttrListPtr().addAttr(M->getContext(), AttrListPtr::FunctionIndex,
+                            Attributes::get(C, B));
     AutoreleaseCallee =
       M->getOrInsertFunction(
         "objc_autorelease",
@@ -3841,12 +3851,13 @@ Constant *ObjCARCContract::getStoreStrongCallee(Module *M) {
     Type *Params[] = { I8XX, I8X };
 
     Attributes::Builder BNoUnwind;
-    BNoUnwind.addNoUnwindAttr();
+    BNoUnwind.addAttribute(Attributes::NoUnwind);
     Attributes::Builder BNoCapture;
-    BNoCapture.addNoCaptureAttr();
+    BNoCapture.addAttribute(Attributes::NoCapture);
     AttrListPtr Attributes = AttrListPtr()
-      .addAttr(~0u, Attributes::get(BNoUnwind))
-      .addAttr(1, Attributes::get(BNoCapture));
+      .addAttr(M->getContext(), AttrListPtr::FunctionIndex,
+               Attributes::get(C, BNoUnwind))
+      .addAttr(M->getContext(), 1, Attributes::get(C, BNoCapture));
 
     StoreStrongCallee =
       M->getOrInsertFunction(
@@ -3864,8 +3875,10 @@ Constant *ObjCARCContract::getRetainAutoreleaseCallee(Module *M) {
     Type *Params[] = { I8X };
     FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false);
     Attributes::Builder B;
-    B.addNoUnwindAttr();
-    AttrListPtr Attributes = AttrListPtr().addAttr(~0u, Attributes::get(B));
+    B.addAttribute(Attributes::NoUnwind);
+    AttrListPtr Attributes =
+      AttrListPtr().addAttr(M->getContext(), AttrListPtr::FunctionIndex,
+                            Attributes::get(C, B));
     RetainAutoreleaseCallee =
       M->getOrInsertFunction("objc_retainAutorelease", FTy, Attributes);
   }
@@ -3879,8 +3892,10 @@ Constant *ObjCARCContract::getRetainAutoreleaseRVCallee(Module *M) {
     Type *Params[] = { I8X };
     FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false);
     Attributes::Builder B;
-    B.addNoUnwindAttr();
-    AttrListPtr Attributes = AttrListPtr().addAttr(~0u, Attributes::get(B));
+    B.addAttribute(Attributes::NoUnwind);
+    AttrListPtr Attributes =
+      AttrListPtr().addAttr(M->getContext(), AttrListPtr::FunctionIndex,
+                            Attributes::get(C, B));
     RetainAutoreleaseRVCallee =
       M->getOrInsertFunction("objc_retainAutoreleaseReturnValue", FTy,
                              Attributes);