Use the AttributeSet when adding multiple attributes and an Attribute::AttrKind
authorBill Wendling <isanbard@gmail.com>
Wed, 23 Jan 2013 00:21:06 +0000 (00:21 +0000)
committerBill Wendling <isanbard@gmail.com>
Wed, 23 Jan 2013 00:21:06 +0000 (00:21 +0000)
when adding a single attribute to the function.

llvm-svn: 173211

clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/TargetInfo.cpp

index aab21a2..0d4e098 100644 (file)
@@ -1257,8 +1257,13 @@ CodeGenModule::GetOrCreateLLVMFunction(StringRef MangledName,
   assert(F->getName() == MangledName && "name was uniqued!");
   if (D.getDecl())
     SetFunctionAttributes(D, F, IsIncompleteFunction);
-  if (ExtraAttrs.hasAttributes())
-    F->addAttribute(llvm::AttributeSet::FunctionIndex, ExtraAttrs);
+  if (ExtraAttrs.hasAttributes()) {
+    llvm::AttrBuilder B(ExtraAttrs);
+    F->addAttributes(llvm::AttributeSet::FunctionIndex,
+                     llvm::AttributeSet::get(VMContext,
+                                             llvm::AttributeSet::FunctionIndex,
+                                             B));
+  }
 
   // This is the first use or definition of a mangled name.  If there is a
   // deferred decl with this name, remember that we need to emit it at the end
index 9811143..6803853 100644 (file)
@@ -1019,8 +1019,10 @@ void X86_32TargetCodeGenInfo::SetTargetAttributes(const Decl *D,
       // Now add the 'alignstack' attribute with a value of 16.
       llvm::AttrBuilder B;
       B.addStackAlignmentAttr(16);
-      Fn->addAttribute(llvm::AttributeSet::FunctionIndex,
-                       llvm::Attribute::get(CGM.getLLVMContext(), B));
+      Fn->addAttributes(llvm::AttributeSet::FunctionIndex,
+                      llvm::AttributeSet::get(CGM.getLLVMContext(),
+                                              llvm::AttributeSet::FunctionIndex,
+                                              B));
     }
   }
 }