[llvm-commits] [llvm] r173210 - in /llvm/trunk: include/llvm/IR/Function.h lib/IR/Function.cpp lib/Transforms/IPO/FunctionAttrs.cpp

Bill Wendling isanbard at gmail.com
Tue Jan 22 16:20:53 PST 2013


Author: void
Date: Tue Jan 22 18:20:53 2013
New Revision: 173210

URL: http://llvm.org/viewvc/llvm-project?rev=173210&view=rev
Log:
Use the AttributeSet when adding multiple attributes and an Attribute::AttrKind
when adding a single attribute to the function.

Modified:
    llvm/trunk/include/llvm/IR/Function.h
    llvm/trunk/lib/IR/Function.cpp
    llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp

Modified: llvm/trunk/include/llvm/IR/Function.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Function.h?rev=173210&r1=173209&r2=173210&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Function.h (original)
+++ llvm/trunk/include/llvm/IR/Function.h Tue Jan 22 18:20:53 2013
@@ -171,7 +171,8 @@
   /// addFnAttr - Add function attributes to this function.
   ///
   void addFnAttr(Attribute::AttrKind N) {
-    addAttribute(AttributeSet::FunctionIndex, Attribute::get(getContext(), N));
+    setAttributes(AttributeList.addAttribute(getContext(),
+                                             AttributeSet::FunctionIndex, N));
   }
 
   /// hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm
@@ -181,10 +182,13 @@
   void setGC(const char *Str);
   void clearGC();
 
-  /// addAttribute - adds the attribute to the list of attributes.
-  void addAttribute(unsigned i, Attribute attr);
+  /// @brief adds the attribute to the list of attributes.
+  void addAttribute(unsigned i, Attribute::AttrKind attr);
 
-  /// removeAttribute - removes the attribute from the list of attributes.
+  /// @brief adds the attributes to the list of attributes.
+  void addAttributes(unsigned i, AttributeSet attrs);
+
+  /// @brief removes the attributes from the list of attributes.
   void removeAttribute(unsigned i, Attribute attr);
 
   /// @brief Extract the alignment for a call or parameter (0=unknown).
@@ -265,7 +269,7 @@
     return AttributeList.hasAttribute(n, Attribute::NoAlias);
   }
   void setDoesNotAlias(unsigned n) {
-    addAttribute(n, Attribute::get(getContext(), Attribute::NoAlias));
+    addAttribute(n, Attribute::NoAlias);
   }
 
   /// @brief Determine if the parameter can be captured.
@@ -274,7 +278,7 @@
     return AttributeList.hasAttribute(n, Attribute::NoCapture);
   }
   void setDoesNotCapture(unsigned n) {
-    addAttribute(n, Attribute::get(getContext(), Attribute::NoCapture));
+    addAttribute(n, Attribute::NoCapture);
   }
 
   /// copyAttributesFrom - copy all additional attributes (those not needed to

Modified: llvm/trunk/lib/IR/Function.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Function.cpp?rev=173210&r1=173209&r2=173210&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Function.cpp (original)
+++ llvm/trunk/lib/IR/Function.cpp Tue Jan 22 18:20:53 2013
@@ -125,7 +125,10 @@
 
 /// addAttr - Add a Attribute to an argument
 void Argument::addAttr(Attribute attr) {
-  getParent()->addAttribute(getArgNo() + 1, attr);
+  AttrBuilder B(attr);
+  getParent()->addAttributes(getArgNo() + 1,
+                             AttributeSet::get(getParent()->getContext(),
+                                               getArgNo() + 1, B));
 }
 
 /// removeAttr - Remove a Attribute from an argument
@@ -248,17 +251,21 @@
     BasicBlocks.begin()->eraseFromParent();
 }
 
-void Function::addAttribute(unsigned i, Attribute attr) {
+void Function::addAttribute(unsigned i, Attribute::AttrKind attr) {
   AttributeSet PAL = getAttributes();
-  AttrBuilder B(attr);
-  PAL = PAL.addAttributes(getContext(), i,
-                          AttributeSet::get(getContext(), i, B));
+  PAL = PAL.addAttribute(getContext(), i, attr);
+  setAttributes(PAL);
+}
+
+void Function::addAttributes(unsigned i, AttributeSet attrs) {
+  AttributeSet PAL = getAttributes();
+  PAL = PAL.addAttributes(getContext(), i, attrs);
   setAttributes(PAL);
 }
 
-void Function::removeAttribute(unsigned i, Attribute attr) {
+void Function::removeAttribute(unsigned i, Attribute attrs) {
   AttributeSet PAL = getAttributes();
-  PAL = PAL.removeAttr(getContext(), i, attr);
+  PAL = PAL.removeAttr(getContext(), i, attrs);
   setAttributes(PAL);
 }
 

Modified: llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp?rev=173210&r1=173209&r2=173210&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp Tue Jan 22 18:20:53 2013
@@ -219,10 +219,8 @@
                        Attribute::get(F->getContext(), B));
 
     // Add in the new attribute.
-    B.clear();
-    B.addAttribute(ReadsMemory ? Attribute::ReadOnly : Attribute::ReadNone);
     F->addAttribute(AttributeSet::FunctionIndex,
-                    Attribute::get(F->getContext(), B));
+                    ReadsMemory ? Attribute::ReadOnly : Attribute::ReadNone);
 
     if (ReadsMemory)
       ++NumReadOnly;





More information about the llvm-commits mailing list