Skip to content

Commit

Permalink
[LangRef] Memset/memcpy/memmove can take undef/poison pointer if the …
Browse files Browse the repository at this point in the history
…size is 0

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.

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D86643
  • Loading branch information
aqjune committed Aug 26, 2020
1 parent 5fbfe2e commit 24dd041
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions llvm/docs/LangRef.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1157,10 +1157,11 @@ Currently, only the following parameter attributes are defined:
``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. ``align 1`` has no effect on
non-byval, non-preallocated arguments.

Note that this attribute has additional semantics when combined with the
``byval`` attribute, which are documented there.
``byval`` or ``preallocated`` attribute, which are documented there.

.. _noalias:

Expand Down Expand Up @@ -12478,8 +12479,8 @@ overlap. It copies "len" bytes of memory over. If the argument is known
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``
pointers. However, they must still be appropriately aligned.

.. _int_memcpy_inline:

Expand Down Expand Up @@ -12535,8 +12536,8 @@ overlap. It copies "len" bytes of memory over. If the argument is known
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``
pointers. However, they must still be appropriately aligned.

The generated code is guaranteed not to call any external functions.

Expand Down Expand Up @@ -12595,8 +12596,8 @@ copies "len" bytes of memory over. If the argument is known 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``
pointers. However, they must still be appropriately aligned.

.. _int_memset:

Expand Down Expand Up @@ -12650,8 +12651,8 @@ at the destination location. If the argument is known 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 pointer may be NULL, dangling, ``undef``, or ``poison``
pointer. However, it must still be appropriately aligned.

'``llvm.sqrt.*``' Intrinsic
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down

0 comments on commit 24dd041

Please sign in to comment.