summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormiod <miod@openbsd.org>2011-11-25 05:21:44 +0000
committermiod <miod@openbsd.org>2011-11-25 05:21:44 +0000
commitb27d36115513e8f91c5e0877db8e601a0b2bb07e (patch)
tree41babeabc95111052641d51bec2d97b74968aa31
parentGratuitous major crank for upcoming alpha switch to gcc 4, in order to have (diff)
downloadwireguard-openbsd-b27d36115513e8f91c5e0877db8e601a0b2bb07e.tar.xz
wireguard-openbsd-b27d36115513e8f91c5e0877db8e601a0b2bb07e.zip
Allow MD backend to prevent the optimization of a bcopy() or memmove() of
size 1 (the size being known at compile-time) into an inline mempcpy() expansion, which will in turn expand into a byte load and store operation. This expansion loses precious address alignment information at some point (because everybody knows that you can read a byte from any address, right?), and this loses bigtime on strict alignment platforms which lack the ability to accesse bytes directly, such as alpha (unless compiling with -mbwx and runnning on a BWX-capable cpu). An example of such call with size 1 is lib/libkvm/kvm.c line 780.
-rw-r--r--gnu/gcc/gcc/builtins.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/gnu/gcc/gcc/builtins.c b/gnu/gcc/gcc/builtins.c
index f6c00447aa6..7a927d2d6da 100644
--- a/gnu/gcc/gcc/builtins.c
+++ b/gnu/gcc/gcc/builtins.c
@@ -3060,10 +3060,19 @@ expand_builtin_memmove (tree arglist, tree type, rtx target,
it is ok to use memcpy as well. */
if (integer_onep (len))
{
- rtx ret = expand_builtin_mempcpy (arglist, type, target, mode,
- /*endp=*/0);
- if (ret)
- return ret;
+#if defined(SUBWORD_ACCESS_P)
+ if (SUBWORD_ACCESS_P
+ || (src_align >= BIGGEST_ALIGNMENT
+ && dest_align >= BIGGEST_ALIGNMENT))
+ {
+#endif
+ rtx ret = expand_builtin_mempcpy (arglist, type, target, mode,
+ /*endp=*/0);
+ if (ret)
+ return ret;
+#if defined(SUBWORD_ACCESS_P)
+ }
+#endif
}
/* Otherwise, call the normal function. */