[cfe-commits] r165611 - in /cfe/trunk/lib/CodeGen: CGCall.cpp CGExpr.cpp CGObjCMac.cpp CGStmt.cpp CodeGenModule.h ItaniumCXXABI.cpp

Bill Wendling isanbard at gmail.com
Wed Oct 10 00:36:57 PDT 2012


Author: void
Date: Wed Oct 10 02:36:56 2012
New Revision: 165611

URL: http://llvm.org/viewvc/llvm-project?rev=165611&view=rev
Log:
Remove the final bits of Attributes being declared in the Attribute
namespace. Use the attribute's enum value instead. No functionality change
intended.

Modified:
    cfe/trunk/lib/CodeGen/CGCall.cpp
    cfe/trunk/lib/CodeGen/CGExpr.cpp
    cfe/trunk/lib/CodeGen/CGObjCMac.cpp
    cfe/trunk/lib/CodeGen/CGStmt.cpp
    cfe/trunk/lib/CodeGen/CodeGenModule.h
    cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=165611&r1=165610&r2=165611&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Wed Oct 10 02:36:56 2012
@@ -924,50 +924,50 @@
                                            const Decl *TargetDecl,
                                            AttributeListType &PAL,
                                            unsigned &CallingConv) {
-  llvm::Attributes FuncAttrs;
-  llvm::Attributes RetAttrs;
+  llvm::Attributes::Builder FuncAttrs;
+  llvm::Attributes::Builder RetAttrs;
 
   CallingConv = FI.getEffectiveCallingConvention();
 
   if (FI.isNoReturn())
-    FuncAttrs |= llvm::Attribute::NoReturn;
+    FuncAttrs.addAttribute(llvm::Attributes::NoReturn);
 
   // FIXME: handle sseregparm someday...
   if (TargetDecl) {
     if (TargetDecl->hasAttr<ReturnsTwiceAttr>())
-      FuncAttrs |= llvm::Attribute::ReturnsTwice;
+      FuncAttrs.addAttribute(llvm::Attributes::ReturnsTwice);
     if (TargetDecl->hasAttr<NoThrowAttr>())
-      FuncAttrs |= llvm::Attribute::NoUnwind;
+      FuncAttrs.addAttribute(llvm::Attributes::NoUnwind);
     else if (const FunctionDecl *Fn = dyn_cast<FunctionDecl>(TargetDecl)) {
       const FunctionProtoType *FPT = Fn->getType()->getAs<FunctionProtoType>();
       if (FPT && FPT->isNothrow(getContext()))
-        FuncAttrs |= llvm::Attribute::NoUnwind;
+        FuncAttrs.addAttribute(llvm::Attributes::NoUnwind);
     }
 
     if (TargetDecl->hasAttr<NoReturnAttr>())
-      FuncAttrs |= llvm::Attribute::NoReturn;
+      FuncAttrs.addAttribute(llvm::Attributes::NoReturn);
 
     if (TargetDecl->hasAttr<ReturnsTwiceAttr>())
-      FuncAttrs |= llvm::Attribute::ReturnsTwice;
+      FuncAttrs.addAttribute(llvm::Attributes::ReturnsTwice);
 
     // 'const' and 'pure' attribute functions are also nounwind.
     if (TargetDecl->hasAttr<ConstAttr>()) {
-      FuncAttrs |= llvm::Attribute::ReadNone;
-      FuncAttrs |= llvm::Attribute::NoUnwind;
+      FuncAttrs.addAttribute(llvm::Attributes::ReadNone);
+      FuncAttrs.addAttribute(llvm::Attributes::NoUnwind);
     } else if (TargetDecl->hasAttr<PureAttr>()) {
-      FuncAttrs |= llvm::Attribute::ReadOnly;
-      FuncAttrs |= llvm::Attribute::NoUnwind;
+      FuncAttrs.addAttribute(llvm::Attributes::ReadOnly);
+      FuncAttrs.addAttribute(llvm::Attributes::NoUnwind);
     }
     if (TargetDecl->hasAttr<MallocAttr>())
-      RetAttrs |= llvm::Attribute::NoAlias;
+      RetAttrs.addAttribute(llvm::Attributes::NoAlias);
   }
 
   if (CodeGenOpts.OptimizeSize)
-    FuncAttrs |= llvm::Attribute::OptimizeForSize;
+    FuncAttrs.addAttribute(llvm::Attributes::OptimizeForSize);
   if (CodeGenOpts.DisableRedZone)
-    FuncAttrs |= llvm::Attribute::NoRedZone;
+    FuncAttrs.addAttribute(llvm::Attributes::NoRedZone);
   if (CodeGenOpts.NoImplicitFloat)
-    FuncAttrs |= llvm::Attribute::NoImplicitFloat;
+    FuncAttrs.addAttribute(llvm::Attributes::NoImplicitFloat);
 
   QualType RetTy = FI.getReturnType();
   unsigned Index = 1;
@@ -975,24 +975,27 @@
   switch (RetAI.getKind()) {
   case ABIArgInfo::Extend:
    if (RetTy->hasSignedIntegerRepresentation())
-     RetAttrs |= llvm::Attribute::SExt;
+     RetAttrs.addAttribute(llvm::Attributes::SExt);
    else if (RetTy->hasUnsignedIntegerRepresentation())
-     RetAttrs |= llvm::Attribute::ZExt;
+     RetAttrs.addAttribute(llvm::Attributes::ZExt);
     break;
   case ABIArgInfo::Direct:
   case ABIArgInfo::Ignore:
     break;
 
   case ABIArgInfo::Indirect: {
-    llvm::Attributes SRETAttrs = llvm::Attribute::StructRet;
+    llvm::Attributes::Builder SRETAttrs;
+    SRETAttrs.addAttribute(llvm::Attributes::StructRet);
     if (RetAI.getInReg())
-      SRETAttrs |= llvm::Attribute::InReg;
-    PAL.push_back(llvm::AttributeWithIndex::get(Index, SRETAttrs));
+      SRETAttrs.addAttribute(llvm::Attributes::InReg);
+    PAL.push_back(llvm::
+                  AttributeWithIndex::get(Index,
+                                          llvm::Attributes::get(SRETAttrs)));
 
     ++Index;
     // sret disables readnone and readonly
-    FuncAttrs &= ~(llvm::Attribute::ReadOnly |
-                   llvm::Attribute::ReadNone);
+    FuncAttrs.removeAttribute(llvm::Attributes::ReadOnly)
+      .removeAttribute(llvm::Attributes::ReadNone);
     break;
   }
 
@@ -1000,14 +1003,16 @@
     llvm_unreachable("Invalid ABI kind for return argument");
   }
 
-  if (RetAttrs)
-    PAL.push_back(llvm::AttributeWithIndex::get(0, RetAttrs));
+  if (RetAttrs.hasAttributes())
+    PAL.push_back(llvm::
+                  AttributeWithIndex::get(0,
+                                          llvm::Attributes::get(RetAttrs)));
 
   for (CGFunctionInfo::const_arg_iterator it = FI.arg_begin(),
          ie = FI.arg_end(); it != ie; ++it) {
     QualType ParamType = it->type;
     const ABIArgInfo &AI = it->info;
-    llvm::Attributes Attrs;
+    llvm::Attributes::Builder Attrs;
 
     // 'restrict' -> 'noalias' is done in EmitFunctionProlog when we
     // have the corresponding parameter variable.  It doesn't make
@@ -1015,13 +1020,13 @@
     switch (AI.getKind()) {
     case ABIArgInfo::Extend:
       if (ParamType->isSignedIntegerOrEnumerationType())
-        Attrs |= llvm::Attribute::SExt;
+        Attrs.addAttribute(llvm::Attributes::SExt);
       else if (ParamType->isUnsignedIntegerOrEnumerationType())
-        Attrs |= llvm::Attribute::ZExt;
+        Attrs.addAttribute(llvm::Attributes::ZExt);
       // FALL THROUGH
     case ABIArgInfo::Direct:
       if (AI.getInReg())
-          Attrs |= llvm::Attribute::InReg;
+        Attrs.addAttribute(llvm::Attributes::InReg);
 
       // FIXME: handle sseregparm someday...
 
@@ -1031,22 +1036,23 @@
       if (llvm::StructType *STy =
           dyn_cast<llvm::StructType>(AI.getCoerceToType())) {
         unsigned Extra = STy->getNumElements()-1;  // 1 will be added below.
-        if (Attrs != llvm::Attribute::None)
+        if (Attrs.hasAttributes())
           for (unsigned I = 0; I < Extra; ++I)
-            PAL.push_back(llvm::AttributeWithIndex::get(Index + I, Attrs));
+            PAL.push_back(llvm::AttributeWithIndex::get(Index + I,
+                                                 llvm::Attributes::get(Attrs)));
         Index += Extra;
       }
       break;
 
     case ABIArgInfo::Indirect:
       if (AI.getIndirectByVal())
-        Attrs |= llvm::Attribute::ByVal;
+        Attrs.addAttribute(llvm::Attributes::ByVal);
+
+      Attrs.addAlignmentAttr(AI.getIndirectAlign());
 
-      Attrs |=
-        llvm::Attributes::constructAlignmentFromInt(AI.getIndirectAlign());
       // byval disables readnone and readonly.
-      FuncAttrs &= ~(llvm::Attribute::ReadOnly |
-                     llvm::Attribute::ReadNone);
+      FuncAttrs.removeAttribute(llvm::Attributes::ReadOnly)
+        .removeAttribute(llvm::Attributes::ReadNone);
       break;
 
     case ABIArgInfo::Ignore:
@@ -1064,12 +1070,14 @@
     }
     }
 
-    if (Attrs)
-      PAL.push_back(llvm::AttributeWithIndex::get(Index, Attrs));
+    if (Attrs.hasAttributes())
+      PAL.push_back(llvm::AttributeWithIndex::get(Index,
+                                                 llvm::Attributes::get(Attrs)));
     ++Index;
   }
-  if (FuncAttrs)
-    PAL.push_back(llvm::AttributeWithIndex::get(~0, FuncAttrs));
+  if (FuncAttrs.hasAttributes())
+    PAL.push_back(llvm::AttributeWithIndex::get(~0,
+                                             llvm::Attributes::get(FuncAttrs)));
 }
 
 /// An argument came in as a promoted argument; demote it back to its
@@ -1117,7 +1125,9 @@
   // Name the struct return argument.
   if (CGM.ReturnTypeUsesSRet(FI)) {
     AI->setName("agg.result");
-    AI->addAttr(llvm::Attribute::NoAlias);
+    llvm::Attributes::Builder B;
+    B.addAttribute(llvm::Attributes::NoAlias);
+    AI->addAttr(llvm::Attributes::get(B));
     ++AI;
   }
 
@@ -1186,8 +1196,11 @@
         assert(AI != Fn->arg_end() && "Argument mismatch!");
         llvm::Value *V = AI;
 
-        if (Arg->getType().isRestrictQualified())
-          AI->addAttr(llvm::Attribute::NoAlias);
+        if (Arg->getType().isRestrictQualified()) {
+          llvm::Attributes::Builder B;
+          B.addAttribute(llvm::Attributes::NoAlias);
+          AI->addAttr(llvm::Attributes::get(B));
+        }
 
         // Ensure the argument is the correct type.
         if (V->getType() != ArgI.getCoerceToType())
@@ -2127,7 +2140,7 @@
   llvm::AttrListPtr Attrs = llvm::AttrListPtr::get(AttributeList);
 
   llvm::BasicBlock *InvokeDest = 0;
-  if (!(Attrs.getFnAttributes() & llvm::Attribute::NoUnwind))
+  if (!Attrs.getFnAttributes().hasAttribute(llvm::Attributes::NoUnwind))
     InvokeDest = getInvokeDest();
 
   llvm::CallSite CS;

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=165611&r1=165610&r2=165611&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Wed Oct 10 02:36:56 2012
@@ -2079,11 +2079,13 @@
 
   llvm::FunctionType *FnType =
     llvm::FunctionType::get(CGM.VoidTy, ArgTypes, false);
+  llvm::Attributes::Builder B;
+  B.addAttribute(llvm::Attributes::NoReturn)
+    .addAttribute(llvm::Attributes::NoUnwind)
+    .addAttribute(llvm::Attributes::UWTable);
   llvm::Value *Fn = CGM.CreateRuntimeFunction(FnType,
                                           ("__ubsan_handle_" + CheckName).str(),
-                                              llvm::Attribute::NoReturn |
-                                              llvm::Attribute::NoUnwind |
-                                              llvm::Attribute::UWTable);
+                                              llvm::Attributes::get(B));
   llvm::CallInst *HandlerCall = Builder.CreateCall(Fn, Args);
   HandlerCall->setDoesNotReturn();
   HandlerCall->setDoesNotThrow();

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=165611&r1=165610&r2=165611&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Wed Oct 10 02:36:56 2012
@@ -63,10 +63,12 @@
     // Add the non-lazy-bind attribute, since objc_msgSend is likely to
     // be called a lot.
     llvm::Type *params[] = { ObjectPtrTy, SelectorPtrTy };
+    llvm::Attributes::Builder B;
+    B.addAttribute(llvm::Attributes::NonLazyBind);
     return CGM.CreateRuntimeFunction(llvm::FunctionType::get(ObjectPtrTy,
                                                              params, true),
                                      "objc_msgSend",
-                                     llvm::Attribute::NonLazyBind);
+                                     llvm::Attributes::get(B));
   }
 
   /// void objc_msgSend_stret (id, SEL, ...)
@@ -580,10 +582,12 @@
   llvm::Constant *getSetJmpFn() {
     // This is specifically the prototype for x86.
     llvm::Type *params[] = { CGM.Int32Ty->getPointerTo() };
+    llvm::Attributes::Builder B;
+    B.addAttribute(llvm::Attributes::NonLazyBind);
     return CGM.CreateRuntimeFunction(llvm::FunctionType::get(CGM.Int32Ty,
                                                              params, false),
                                      "_setjmp",
-                                     llvm::Attribute::ReturnsTwice);
+                                     llvm::Attributes::get(B));
   }
 
 public:

Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=165611&r1=165610&r2=165611&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Wed Oct 10 02:36:56 2012
@@ -1632,7 +1632,9 @@
     llvm::InlineAsm::get(FTy, AsmString, Constraints, HasSideEffect,
                          /* IsAlignStack */ false, AsmDialect);
   llvm::CallInst *Result = Builder.CreateCall(IA, Args);
-  Result->addAttribute(~0, llvm::Attribute::NoUnwind);
+  llvm::Attributes::Builder B;
+  B.addAttribute(llvm::Attributes::NoUnwind);
+  Result->addAttribute(~0, llvm::Attributes::get(B));
 
   // Slap the source location of the inline asm into a !srcloc metadata on the
   // call.  FIXME: Handle metadata for MS-style inline asms.

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=165611&r1=165610&r2=165611&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Wed Oct 10 02:36:56 2012
@@ -702,7 +702,7 @@
   llvm::Constant *CreateRuntimeFunction(llvm::FunctionType *Ty,
                                         StringRef Name,
                                         llvm::Attributes ExtraAttrs =
-                                          llvm::Attribute::None);
+                                          llvm::Attributes());
   /// CreateRuntimeVariable - Create a new runtime global variable with the
   /// specified type and name.
   llvm::Constant *CreateRuntimeVariable(llvm::Type *Ty,
@@ -881,7 +881,7 @@
                                           GlobalDecl D,
                                           bool ForVTable,
                                           llvm::Attributes ExtraAttrs =
-                                            llvm::Attribute::None);
+                                            llvm::Attributes());
   llvm::Constant *GetOrCreateLLVMGlobal(StringRef MangledName,
                                         llvm::PointerType *PTy,
                                         const VarDecl *D,

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=165611&r1=165610&r2=165611&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Wed Oct 10 02:36:56 2012
@@ -950,9 +950,10 @@
   llvm::FunctionType *FTy =
     llvm::FunctionType::get(CGM.getTypes().ConvertType(CGM.getContext().IntTy),
                             GuardPtrTy, /*isVarArg=*/false);
-  
+  llvm::Attributes::Builder B;
+  B.addAttribute(llvm::Attributes::NoUnwind);
   return CGM.CreateRuntimeFunction(FTy, "__cxa_guard_acquire",
-                                   llvm::Attribute::NoUnwind);
+                                   llvm::Attributes::get(B));
 }
 
 static llvm::Constant *getGuardReleaseFn(CodeGenModule &CGM,
@@ -960,9 +961,10 @@
   // void __cxa_guard_release(__guard *guard_object);
   llvm::FunctionType *FTy =
     llvm::FunctionType::get(CGM.VoidTy, GuardPtrTy, /*isVarArg=*/false);
-  
+  llvm::Attributes::Builder B;
+  B.addAttribute(llvm::Attributes::NoUnwind);
   return CGM.CreateRuntimeFunction(FTy, "__cxa_guard_release",
-                                   llvm::Attribute::NoUnwind);
+                                   llvm::Attributes::get(B));
 }
 
 static llvm::Constant *getGuardAbortFn(CodeGenModule &CGM,
@@ -970,9 +972,10 @@
   // void __cxa_guard_abort(__guard *guard_object);
   llvm::FunctionType *FTy =
     llvm::FunctionType::get(CGM.VoidTy, GuardPtrTy, /*isVarArg=*/false);
-  
+  llvm::Attributes::Builder B;
+  B.addAttribute(llvm::Attributes::NoUnwind);
   return CGM.CreateRuntimeFunction(FTy, "__cxa_guard_abort",
-                                   llvm::Attribute::NoUnwind);
+                                   llvm::Attributes::get(B));
 }
 
 namespace {





More information about the cfe-commits mailing list