[PATCH] Handle copy between non-identical, but structurally equal RECORD_TYPEs in SRA (PR c++/35144)

Richard Guenther richard.guenther@gmail.com
Tue Feb 12 17:18:00 GMT 2008


On Feb 12, 2008 4:35 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> The pointer to member function RECORD_TYPEs C++ FE creates have the same
> fields and for useless_type_conversion_p are considered compatible (so it is
> valid GIMPLE to copy one to the other, yet they have different
> TYPE_MAIN_VARIANTs and different FIELD_DECLs.
>
> SRA currently uses FIELD_DECLs to look up the elements, which will not work.
> The following patch adjusts generate_element_copy to try harder, if
> DST's FIELD_DECL wasn't found in SRC, it will try to locate a SRC FIELD_DECL
> with the same field offset, size and compatible type.
>
> Unfortunately, the pointer to member function RECORD_TYPEs sometimes have
> pointers to different METHOD_TYPEs, and useless_type_conversion_p doesn't
> consider those to be equivalent, so the extra POINTER_TYPE_P checks
> in generate_element_copy and additional hunk in sra_build_assignment
> are there to convert the pointers.
>
> Bootstrapped/regtested on x86_64-linux, ok for trunk?

Ok.

Thanks,
Richard.

> 2008-02-12  Jakub Jelinek  <jakub@redhat.com>
>
>         PR c++/35144
>         * tree-sra.c (sra_build_assignment): fold_convert SRC if copying
>         non-compatible pointers.
>         (generate_element_copy): If SRC and DST are RECORD_TYPEs with
>         different FIELD_DECLs, try harder by comparing field offsets, sizes
>         and types.
>
>         * g++.dg/tree-ssa/pr35144.C: New test.



More information about the Gcc-patches mailing list