]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
middle-end/32667 - document cpymem and memcpy exact overlap requirement
authorRichard Biener <rguenther@suse.de>
Thu, 23 Nov 2023 07:54:56 +0000 (08:54 +0100)
committerRichard Biener <rguenther@suse.de>
Thu, 23 Nov 2023 08:28:21 +0000 (09:28 +0100)
The following amends the cpymem documentation to mention that exact
overlap needs to be handled gracefully, also noting that the target
runtime is expected to behave the same way where -ffreestanding
docs mention the set of routines required.

PR middle-end/32667
* doc/md.texi (cpymem): Document that exact overlap of source
and destination needs to work.
* doc/standards.texi (ffreestanding): Mention memcpy is required
to handle the exact overlap case.

gcc/doc/md.texi
gcc/doc/standards.texi

index df6725ffc9c260a3d0f59723ca57fd3ab6b92334..536ce997f01957bbe1a893993f751d35d7cd2a20 100644 (file)
@@ -6915,8 +6915,9 @@ individually copied data units in the block.
 
 The @code{cpymem@var{m}} patterns need not give special consideration
 to the possibility that the source and destination strings might
-overlap. These patterns are used to do inline expansion of
-@code{__builtin_memcpy}.
+overlap.  An exception is the case where source and destination are
+equal, this case needs to be handled correctly.
+These patterns are used to do inline expansion of @code{__builtin_memcpy}.
 
 @cindex @code{movmem@var{m}} instruction pattern
 @item @samp{movmem@var{m}}
index 4eb43f14f90414f65f71e7273d6e1807bd1cbdc3..6eebb9426f3ddb4d431ad869532f7cf0f44da320 100644 (file)
@@ -184,7 +184,9 @@ GNU C library).  @xref{Standard Libraries,,Standard Libraries}.
 Most of the compiler support routines used by GCC are present in
 @file{libgcc}, but there are a few exceptions.  GCC requires the
 freestanding environment provide @code{memcpy}, @code{memmove},
-@code{memset} and @code{memcmp}.
+@code{memset} and @code{memcmp}.  Contrary to the standards
+covering @code{memcpy} GCC expects the case of an exact overlap
+of source and destination to work and not invoke undefined behavior.
 Finally, if @code{__builtin_trap} is used, and the target does
 not implement the @code{trap} pattern, then GCC emits a call
 to @code{abort}.