[PATCH] D86643: [LangRef] Memset/memcpy/memmove can take undef/poison pointer if the size is 0

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 26 10:14:51 PDT 2020


aqjune created this revision.
aqjune added reviewers: jdoerfert, efriedma.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
aqjune requested review of this revision.

According to the current LangRef, Memset/memcpy/memmove can take a
null/dangling pointer if the size is zero.
(Relevant thread: http://lists.llvm.org/pipermail/llvm-dev/2017-July/115665.html )
This patch expands it and allows the functions to take undef/poison pointers
too.

This required the updates in the align attribute since it isn't specified
what is the alignment of undef/poison pointers.
This patch states that their alignment is 1.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86643

Files:
  llvm/docs/LangRef.rst


Index: llvm/docs/LangRef.rst
===================================================================
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -1157,7 +1157,8 @@
 ``align <n>`` or ``align(<n>)``
     This indicates that the pointer value may be assumed by the optimizer to
     have the specified alignment.  If the pointer value does not have the
-    specified alignment, behavior is undefined.
+    specified alignment, behavior is undefined. ``undef`` and ``poison``
+    pointers have alignment 1.
 
     Note that this attribute has additional semantics when combined with the
     ``byval`` attribute, which are documented there.
@@ -12478,8 +12479,8 @@
 to be aligned to some boundary, this can be specified as an attribute on
 the argument.
 
-If "len" is 0, the pointers may be NULL or dangling. However, they must still
-be appropriately aligned.
+If "len" is 0, the pointers may be NULL, dangling, ``undef``, or ``poison``.
+However, they must still be appropriately aligned.
 
 .. _int_memcpy_inline:
 
@@ -12535,8 +12536,8 @@
 to be aligned to some boundary, this can be specified as an attribute on
 the argument.
 
-If "len" is 0, the pointers may be NULL or dangling. However, they must still
-be appropriately aligned.
+If "len" is 0, the pointers may be NULL, dangling, ``undef``, or ``poison``.
+However, they must still be appropriately aligned.
 
 The generated code is guaranteed not to call any external functions.
 
@@ -12595,8 +12596,8 @@
 aligned to some boundary, this can be specified as an attribute on
 the argument.
 
-If "len" is 0, the pointers may be NULL or dangling. However, they must still
-be appropriately aligned.
+If "len" is 0, the pointers may be NULL, dangling, ``undef``, or ``poison``.
+However, they must still be appropriately aligned.
 
 .. _int_memset:
 
@@ -12650,8 +12651,8 @@
 aligned to some boundary, this can be specified as an attribute on
 the argument.
 
-If "len" is 0, the pointers may be NULL or dangling. However, they must still
-be appropriately aligned.
+If "len" is 0, the pointers may be NULL, dangling, ``undef``, or ``poison``.
+However, they must still be appropriately aligned.
 
 '``llvm.sqrt.*``' Intrinsic
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86643.288025.patch
Type: text/x-patch
Size: 2221 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200826/52c96397/attachment.bin>


More information about the llvm-commits mailing list