This is the mail archive of the gcc@gcc.gnu.org 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: fold_builtin_memcpy cannot optimize <retval>?


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.

	Jakub


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