This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: __builtin_memcpy and alignment assumptions

On Fri, Jan 8, 2016 at 12:24 PM, Eric Botcazou <> wrote:
>> See some existing PR.  The GCC middle-end cannot assume that pointers
>> are aligned according to their type (while at least the C language would
>> support that notion).
> Only on x86.  It could (and used to) do it on strict-alignment architectures.

As the GIMPLE type system treats all pointer types equal (independet
on alignment)
"random" types may end up in the actual arguments of the memcpy (because what
matters is the pointer value, not the type).  In practice this is of
course usually one
of the types in an original conversion chain and thus "fine" if the
source language is C.

I don't see that it should be dependent on strict-alignment or not
(such special-cases
of interpreting source language semantics are bad for portability).

In the middle-end (including RTL) alignment is on memory references
and the issue
with things like memcpy is that it is not treated as "memory
reference" with explicitely
recorded alignments.

I doubt "used to do it" has applied to say

void foo (int *p)
   if (p & ~3)
    link_error ();


> --
> Eric Botcazou

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]