[llvm] r185735 - Extend 'readonly' and 'readnone' to work on function arguments as well as

Chandler Carruth chandlerc at google.com
Fri Jul 5 17:49:50 PDT 2013


Ahh, later on you even have the latter option for CallSite:

Modified: llvm/trunk/include/llvm/Support/CallSite.h
URL:
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CallSite.h?rev=185735&r1=185734&r2=185735&view=diff
============================================================
==================
--- llvm/trunk/include/llvm/Support/CallSite.h (original)
+++ llvm/trunk/include/llvm/Support/CallSite.h Fri Jul  5 19:29:58 2013
@@ -257,6 +257,15 @@ public:
     return paramHasAttr(ArgNo + 1, Attribute::ByVal);
   }

+  bool doesNotAccessMemory(unsigned ArgNo) const {
+    return paramHasAttr(ArgNo + 1, Attribute::ReadNone);
+  }
+
+  bool onlyReadsMemory(unsigned ArgNo) const {
+    return paramHasAttr(ArgNo + 1, Attribute::ReadOnly) ||
+           paramHasAttr(ArgNo + 1, Attribute::ReadNone);
+  }
+


On Fri, Jul 5, 2013 at 5:48 PM, Chandler Carruth <chandlerc at google.com>wrote:

>
> On Fri, Jul 5, 2013 at 5:29 PM, Nick Lewycky <nicholas at mxc.ca> wrote:
>
>> +  bool onlyReadsMemory(unsigned n) const {
>> +    return AttributeSets.hasAttribute(n, Attribute::ReadOnly) ||
>> +           AttributeSets.hasAttribute(n, Attribute::ReadNone);
>> +  }
>> +  void setOnlyReadsMemory(unsigned n) {
>> +    addAttribute(n, Attribute::ReadOnly);
>> +  }
>> +
>>
>
> It seems weird interface wise to only expose this in the 'or' form. I know
> the only user you have today expects that form, but interface wise it would
> seem cleaner to either expose the attribute semantics directly, or to
> expose an OR of the attributes and the readnone separately (as readnone is
> essentially a strict subset of readonly).
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130705/f0b7d91f/attachment.html>


More information about the llvm-commits mailing list