[PATCH] D46240: [llvm] Removing writeonly and readnone incompatibility.

Brian Homerding via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 29 14:11:43 PDT 2018


homerdin created this revision.
homerdin added reviewers: reames, hfinkel.

It seems writeonly is a subset of readnone and are compatible.  This corresponds to the beginning of the documentation on readnone.

> On a function, this attribute indicates that the function computes its result (or decides to unwind an exception) based strictly on its arguments, without dereferencing any pointer arguments or otherwise accessing any mutable state (e.g. memory, control registers, etc) visible to caller functions.

However the next part of readnone's documentation seems unrelated to the readnone attribute and would conflict with writeonly.

> It does not write through any pointer arguments (including byval arguments) and never changes any state visible to callers.

This patch would remove the conflict between writeonly and readnone.


https://reviews.llvm.org/D46240

Files:
  docs/LangRef.rst
  lib/IR/Verifier.cpp
  test/Verifier/writeonly.ll


Index: test/Verifier/writeonly.ll
===================================================================
--- test/Verifier/writeonly.ll
+++ test/Verifier/writeonly.ll
@@ -1,8 +1,5 @@
 ; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s
 
-declare void @a() readnone writeonly
-; CHECK: Attributes {{.*}} are incompatible
-
 declare void @b() readonly writeonly
 ; CHECK: Attributes {{.*}} are incompatible
 
Index: lib/IR/Verifier.cpp
===================================================================
--- lib/IR/Verifier.cpp
+++ lib/IR/Verifier.cpp
@@ -1523,12 +1523,6 @@
          "'readnone and readonly' are incompatible!",
          V);
 
-  Assert(!(Attrs.hasAttribute(Attribute::ReadNone) &&
-           Attrs.hasAttribute(Attribute::WriteOnly)),
-         "Attributes "
-         "'readnone and writeonly' are incompatible!",
-         V);
-
   Assert(!(Attrs.hasAttribute(Attribute::ReadOnly) &&
            Attrs.hasAttribute(Attribute::WriteOnly)),
          "Attributes "
@@ -1660,10 +1654,6 @@
            Attrs.hasFnAttribute(Attribute::ReadOnly)),
          "Attributes 'readnone and readonly' are incompatible!", V);
 
-  Assert(!(Attrs.hasFnAttribute(Attribute::ReadNone) &&
-           Attrs.hasFnAttribute(Attribute::WriteOnly)),
-         "Attributes 'readnone and writeonly' are incompatible!", V);
-
   Assert(!(Attrs.hasFnAttribute(Attribute::ReadOnly) &&
            Attrs.hasFnAttribute(Attribute::WriteOnly)),
          "Attributes 'readonly and writeonly' are incompatible!", V);
Index: docs/LangRef.rst
===================================================================
--- docs/LangRef.rst
+++ docs/LangRef.rst
@@ -1524,9 +1524,7 @@
     result (or decides to unwind an exception) based strictly on its arguments,
     without dereferencing any pointer arguments or otherwise accessing
     any mutable state (e.g. memory, control registers, etc) visible to
-    caller functions. It does not write through any pointer arguments
-    (including ``byval`` arguments) and never changes any state visible
-    to callers. This means while it cannot unwind exceptions by calling
+    caller functions. This means while it cannot unwind exceptions by calling
     the ``C++`` exception throwing methods (since they write to memory), there may
     be non-``C++`` mechanisms that throw exceptions without writing to LLVM
     visible memory.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46240.144496.patch
Type: text/x-patch
Size: 2367 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180429/efe9e6de/attachment.bin>


More information about the llvm-commits mailing list