]> granicus.if.org Git - clang/commitdiff
Attributes Rewrite
authorBill Wendling <isanbard@gmail.com>
Mon, 15 Oct 2012 04:47:45 +0000 (04:47 +0000)
committerBill Wendling <isanbard@gmail.com>
Mon, 15 Oct 2012 04:47:45 +0000 (04:47 +0000)
Convert the uses of the Attributes class over to the new format. The
Attributes::get method call now takes an LLVM context so that the attributes
object can be uniquified and stored.

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

lib/CodeGen/CGCall.cpp
lib/CodeGen/CGExpr.cpp
lib/CodeGen/CGObjCMac.cpp
lib/CodeGen/CGStmt.cpp
lib/CodeGen/CodeGenModule.cpp
lib/CodeGen/ItaniumCXXABI.cpp
lib/CodeGen/TargetInfo.cpp

index e8d99e2f5a01964f3e9173954181b702befdb6ac..15db9fd305f160bf391a754457a0c3aff70b4df7 100644 (file)
@@ -990,7 +990,8 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI,
       SRETAttrs.addAttribute(llvm::Attributes::InReg);
     PAL.push_back(llvm::
                   AttributeWithIndex::get(Index,
-                                          llvm::Attributes::get(SRETAttrs)));
+                                         llvm::Attributes::get(getLLVMContext(),
+                                                               SRETAttrs)));
 
     ++Index;
     // sret disables readnone and readonly
@@ -1006,7 +1007,8 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI,
   if (RetAttrs.hasAttributes())
     PAL.push_back(llvm::
                   AttributeWithIndex::get(0,
-                                          llvm::Attributes::get(RetAttrs)));
+                                         llvm::Attributes::get(getLLVMContext(),
+                                                               RetAttrs)));
 
   for (CGFunctionInfo::const_arg_iterator it = FI.arg_begin(),
          ie = FI.arg_end(); it != ie; ++it) {
@@ -1039,7 +1041,8 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI,
         if (Attrs.hasAttributes())
           for (unsigned I = 0; I < Extra; ++I)
             PAL.push_back(llvm::AttributeWithIndex::get(Index + I,
-                                                 llvm::Attributes::get(Attrs)));
+                                         llvm::Attributes::get(getLLVMContext(),
+                                                               Attrs)));
         Index += Extra;
       }
       break;
@@ -1072,12 +1075,14 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI,
 
     if (Attrs.hasAttributes())
       PAL.push_back(llvm::AttributeWithIndex::get(Index,
-                                                 llvm::Attributes::get(Attrs)));
+                                         llvm::Attributes::get(getLLVMContext(),
+                                                               Attrs)));
     ++Index;
   }
   if (FuncAttrs.hasAttributes())
     PAL.push_back(llvm::AttributeWithIndex::get(~0,
-                                             llvm::Attributes::get(FuncAttrs)));
+                                         llvm::Attributes::get(getLLVMContext(),
+                                                               FuncAttrs)));
 }
 
 /// An argument came in as a promoted argument; demote it back to its
@@ -1127,7 +1132,7 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
     AI->setName("agg.result");
     llvm::Attributes::Builder B;
     B.addAttribute(llvm::Attributes::NoAlias);
-    AI->addAttr(llvm::Attributes::get(B));
+    AI->addAttr(llvm::Attributes::get(getLLVMContext(), B));
     ++AI;
   }
 
@@ -1199,7 +1204,7 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
         if (Arg->getType().isRestrictQualified()) {
           llvm::Attributes::Builder B;
           B.addAttribute(llvm::Attributes::NoAlias);
-          AI->addAttr(llvm::Attributes::get(B));
+          AI->addAttr(llvm::Attributes::get(getLLVMContext(), B));
         }
 
         // Ensure the argument is the correct type.
index ec521a988bd94345e33b640cee0d8da107fb9aaa..c62b1b10734526b49394c13f28534faa30d56d9c 100644 (file)
@@ -2087,7 +2087,8 @@ void CodeGenFunction::EmitCheck(llvm::Value *Checked, StringRef CheckName,
     .addAttribute(llvm::Attributes::UWTable);
   llvm::Value *Fn = CGM.CreateRuntimeFunction(FnType,
                                           ("__ubsan_handle_" + CheckName).str(),
-                                              llvm::Attributes::get(B));
+                                         llvm::Attributes::get(getLLVMContext(),
+                                                               B));
   llvm::CallInst *HandlerCall = Builder.CreateCall(Fn, Args);
   HandlerCall->setDoesNotReturn();
   HandlerCall->setDoesNotThrow();
index 22ea521f8e8672c4bd79b3841d4586d3b10905a0..749d9d4b04343fae56f7b4a2897d9075223700fd 100644 (file)
@@ -68,7 +68,8 @@ private:
     return CGM.CreateRuntimeFunction(llvm::FunctionType::get(ObjectPtrTy,
                                                              params, true),
                                      "objc_msgSend",
-                                     llvm::Attributes::get(B));
+                                     llvm::Attributes::get(CGM.getLLVMContext(),
+                                                           B));
   }
 
   /// void objc_msgSend_stret (id, SEL, ...)
@@ -587,7 +588,8 @@ public:
     return CGM.CreateRuntimeFunction(llvm::FunctionType::get(CGM.Int32Ty,
                                                              params, false),
                                      "_setjmp",
-                                     llvm::Attributes::get(B));
+                                     llvm::Attributes::get(CGM.getLLVMContext(),
+                                                           B));
   }
 
 public:
index 41a96e82e24ea0adad8df5c2593ea42c615e8835..3b28a61939e78e0f4e222c3bf2cfd30f740fc346 100644 (file)
@@ -1634,7 +1634,7 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
   llvm::CallInst *Result = Builder.CreateCall(IA, Args);
   llvm::Attributes::Builder B;
   B.addAttribute(llvm::Attributes::NoUnwind);
-  Result->addAttribute(~0, llvm::Attributes::get(B));
+  Result->addAttribute(~0, llvm::Attributes::get(getLLVMContext(), B));
 
   // Slap the source location of the inline asm into a !srcloc metadata on the
   // call.  FIXME: Handle metadata for MS-style inline asms.
index 7e688585d09f5473a80e804aff28e18e83276911..073b59ef8dc345ca17afef920d23e4a12aeed62c 100644 (file)
@@ -646,7 +646,8 @@ void CodeGenModule::SetFunctionAttributes(GlobalDecl GD,
   if (unsigned IID = F->getIntrinsicID()) {
     // If this is an intrinsic function, set the function's attributes
     // to the intrinsic's attributes.
-    F->setAttributes(llvm::Intrinsic::getAttributes((llvm::Intrinsic::ID)IID));
+    F->setAttributes(llvm::Intrinsic::getAttributes(getLLVMContext(),
+                                                    (llvm::Intrinsic::ID)IID));
     return;
   }
 
index 4d944301d2ce75d0219ff1ef66d633d2743c99cb..42ca81e6a6a5857c501e717022452fac13f82289 100644 (file)
@@ -953,7 +953,8 @@ static llvm::Constant *getGuardAcquireFn(CodeGenModule &CGM,
   llvm::Attributes::Builder B;
   B.addAttribute(llvm::Attributes::NoUnwind);
   return CGM.CreateRuntimeFunction(FTy, "__cxa_guard_acquire",
-                                   llvm::Attributes::get(B));
+                                   llvm::Attributes::get(CGM.getLLVMContext(),
+                                                         B));
 }
 
 static llvm::Constant *getGuardReleaseFn(CodeGenModule &CGM,
@@ -964,7 +965,8 @@ static llvm::Constant *getGuardReleaseFn(CodeGenModule &CGM,
   llvm::Attributes::Builder B;
   B.addAttribute(llvm::Attributes::NoUnwind);
   return CGM.CreateRuntimeFunction(FTy, "__cxa_guard_release",
-                                   llvm::Attributes::get(B));
+                                   llvm::Attributes::get(CGM.getLLVMContext(),
+                                                         B));
 }
 
 static llvm::Constant *getGuardAbortFn(CodeGenModule &CGM,
@@ -975,7 +977,8 @@ static llvm::Constant *getGuardAbortFn(CodeGenModule &CGM,
   llvm::Attributes::Builder B;
   B.addAttribute(llvm::Attributes::NoUnwind);
   return CGM.CreateRuntimeFunction(FTy, "__cxa_guard_abort",
-                                   llvm::Attributes::get(B));
+                                   llvm::Attributes::get(CGM.getLLVMContext(),
+                                                         B));
 }
 
 namespace {
index d84d57c2bbf2759497861232ea086d7b33c1155a..497adcd7539e912742c02ba8c52011efa87cb175 100644 (file)
@@ -970,7 +970,7 @@ void X86_32TargetCodeGenInfo::SetTargetAttributes(const Decl *D,
       // Now add the 'alignstack' attribute with a value of 16.
       llvm::Attributes::Builder B;
       B.addStackAlignmentAttr(16);
-      Fn->addAttribute(~0U, llvm::Attributes::get(B));
+      Fn->addAttribute(~0U, llvm::Attributes::get(CGM.getLLVMContext(), B));
     }
   }
 }