This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: fold_builtin_memcpy cannot optimize <retval>?
On Fri, 2005-01-21 at 11:51 +0100, Jakub Jelinek wrote:
> On Fri, Jan 21, 2005 at 11:38:37AM +0100, Richard Guenther wrote:
> > The simple testcase
> >
> > struct Foo {};
> > Foo bar(const Foo& a)
> > {
> > Foo res;
> > res = a;
> > return res;
> > }
> >
> > leaves us with
> >
> > Foo bar(const Foo&) (a)
> > {
> > struct Foo res;
> >
> > # BLOCK 0
> > # PRED: ENTRY [100.0%] (fallthru,exec)
> > __builtin_memcpy (&<retval>, a_1, 0);
> > return <retval>;
> > # SUCC: EXIT [100.0%]
> >
> > }
> >
> > in the optimized tree-dump and obviously ugly asm code.
> >
> > What's going on here?
>
> The arguments to __builtin_memcpy fail validation (validate_arglist).
> The reason is that second argument in this case is not POINTER_TYPE
> as memcpy requires, but REFERENCE_TYPE.
>
> Not sure if it is better to just make sure __builtin_memcpy will
> never see a REFERENCE_TYPE argument in this case, or make argument
> validation in builtins.c less strict and for POINTER_TYPE requirements
> allow REFERENCE_TYPEs as well.
I'm not an expert on the differences in the semantics of POINTER_TYPE
and REFERENCE_TYPE, but I do know that I've been treating them as
effectively the same.
Jeff