[PATCH] D9375: An llvm.noalias intrinsic

Hal Finkel via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 7 01:21:18 PDT 2016


hfinkel updated this revision to Diff 63035.
hfinkel added a comment.
Herald added a subscriber: mcrosier.

Wording changes (and rebased)


http://reviews.llvm.org/D9375

Files:
  docs/LangRef.rst
  include/llvm/IR/Intrinsics.td

Index: include/llvm/IR/Intrinsics.td
===================================================================
--- include/llvm/IR/Intrinsics.td
+++ include/llvm/IR/Intrinsics.td
@@ -329,6 +329,13 @@
 // control dependencies will be maintained.
 def int_assume        : Intrinsic<[], [llvm_i1_ty], []>;
 
+// This intrinsic does not actually write to memory, but it is marked that way
+// to maintain proper control dependencies. The metadata argument refers to a
+// list of alias.scope metadata entries.
+def int_noalias       : Intrinsic<[llvm_anyptr_ty],
+                                  [LLVMMatchType<0>, llvm_metadata_ty],
+                                  [IntrReadWriteArgMem]>;
+
 // Stack Protector Intrinsic - The stackprotector intrinsic writes the stack
 // guard to the correct place on the stack frame.
 def int_stackprotector : Intrinsic<[], [llvm_ptr_ty, llvm_ptrptr_ty], []>;
Index: docs/LangRef.rst
===================================================================
--- docs/LangRef.rst
+++ docs/LangRef.rst
@@ -12275,6 +12275,64 @@
 that the optimizer can otherwise deduce or facts that are of little use to the
 optimizer.
 
+.. _int_noalias:
+
+'``llvm.noalias``' Intrinsic
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Syntax:
+"""""""
+
+::
+
+      declare <type>* @llvm.noalias.p<address space><type>(<type>* %ptr, metadata %scopes)
+
+Overview:
+"""""""""
+
+``llvm.noalias`` allows the optimizer to assume that memory accesses using
+pointers :ref:`based <pointeraliasing>` on the return value don't alias with
+memory accesses, tagged with the provided ``noalias`` scope, using pointers not
+derived from the return value.
+
+Arguments:
+""""""""""
+
+The first argument in the pointer on which the aliasing assumption is being
+placed. This pointer value is returned, but parts of the optimizer ignore this
+fact so that data dependencies on the return value will be maintained. The
+aliasing assumptions apply only to uses of pointers
+:ref:`based <pointeraliasing>` on the return value.
+
+The second argument is metadata that is a list of ``noalias`` metadata
+references. The format is identical to that required for ``noalias`` metadata.
+This list should have only one element.
+
+Semantics:
+""""""""""
+
+``llvm.noalias`` allows the optimizer to assume that memory accesses using
+pointers :ref:`based <pointeraliasing>` on from the return value don't alias
+with memory accesses, tagged with compatible ``noalias`` scopes (i.e. the scope
+provided to the intrinsic must be one of the scopes with which the access is
+tagged), using pointers not based on the return value.  See the description of
+``alias.scope`` and ``noalias`` metadata for more information. The aliasing
+assumptions apply only to uses of pointers based on the return value, and
+accesses using those pointers must themselves be tagged with ``noalias``
+metadata with compatible scopes.
+
+Unlike ``alias.scope`` metadata, which applies to only the access to which it
+is attached, the ``llvm.noalias`` intrinsic applies to all pointers based on
+from the return value. Placing an ``llvm.noalias`` intrinsic outside of a loop
+provides a mechanism for communicating that certain memory accesses don't alias
+with uses of a pointer in any loop iteration. This works only if the
+``llvm.noalias`` intrinsic itself dominates the loop body.
+
+Note that the use of ``alias.scope`` metadata does not block potential
+optimizations, as ``llvm.noalias`` might, and so use of  ``alias.scope``
+metadata when possible is recommended. Nevertheless, no code is generated for
+this intrinsic.
+
 .. _type.test:
 
 '``llvm.type.test``' Intrinsic


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9375.63035.patch
Type: text/x-patch
Size: 3629 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160707/da248496/attachment.bin>


More information about the llvm-commits mailing list