This is the mail archive of the gcc-patches@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: [PATCH] Fix -fipa-struct-reorg with unnamed struct fields (PR middle-end/41837)


On Tue, Oct 27, 2009 at 7:07 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> __gcov_info struct has unnamed fields, but in theory other structs could
> have unnamed fields as well. ?This patch makes structs with such fields
> equivalent for ipa-struct-reorg only when they have the same main variant.
>
> Bootstrapped/regtested on x86_64-linux, ok for trunk?

Ok.

Thanks,
Richard.

> 2009-10-27 ?Jakub Jelinek ?<jakub@redhat.com>
>
> ? ? ? ?PR middle-end/41837
> ? ? ? ?* ipa-struct-reorg.c (find_field_in_struct_1): Return NULL if
> ? ? ? ?fields don't have DECL_NAME.
>
> ? ? ? ?* gcc.dg/pr41837.c: New test.
>
> --- gcc/ipa-struct-reorg.c.jj ? 2009-08-03 09:42:42.000000000 +0200
> +++ gcc/ipa-struct-reorg.c ? ? ?2009-10-27 12:34:49.000000000 +0100
> @@ -258,15 +258,21 @@ find_field_in_struct_1 (tree str_type, t
> ?{
> ? tree str_field;
>
> + ?if (!DECL_NAME (field))
> + ? ?return NULL;
> +
> ? for (str_field = TYPE_FIELDS (str_type); str_field;
> ? ? ? ?str_field = TREE_CHAIN (str_field))
> ? ? {
> - ? ? ?const char * str_field_name;
> - ? ? ?const char * field_name;
> + ? ? ?const char *str_field_name;
> + ? ? ?const char *field_name;
> +
> + ? ? ?if (!DECL_NAME (str_field))
> + ? ? ? continue;
>
> ? ? ? str_field_name = IDENTIFIER_POINTER (DECL_NAME (str_field));
> ? ? ? field_name = IDENTIFIER_POINTER (DECL_NAME (field));
> -
> +
> ? ? ? gcc_assert (str_field_name);
> ? ? ? gcc_assert (field_name);
>
> @@ -274,7 +280,7 @@ find_field_in_struct_1 (tree str_type, t
> ? ? ? ?{
> ? ? ? ? ?/* Check field types. ?*/
> ? ? ? ? ?if (is_equal_types (TREE_TYPE (str_field), TREE_TYPE (field)))
> - ? ? ? ? ? ? return str_field;
> + ? ? ? ? ? return str_field;
> ? ? ? ?}
> ? ? }
>
> --- gcc/testsuite/gcc.dg/pr41837.c.jj ? 2009-10-27 13:11:07.000000000 +0100
> +++ gcc/testsuite/gcc.dg/pr41837.c ? ? ?2009-10-27 13:07:03.000000000 +0100
> @@ -0,0 +1,38 @@
> +/* PR middle-end/41837 */
> +/* { dg-do compile } */
> +/* { dg-options "-fipa-struct-reorg -O -fwhole-program -fprofile-generate" } */
> +
> +typedef struct { int a, b; } T1;
> +typedef struct S1 *T2;
> +typedef struct S2 *T3;
> +typedef struct S3 *T4;
> +typedef struct S4 *T5;
> +struct S4 { union { int c; } d; };
> +struct S2 { int e; T2 f; int g; };
> +typedef struct { T3 h; } T6;
> +typedef struct { int i; } *T7;
> +struct S3 { T6 j; T7 k; };
> +
> +void
> +f1 (T4 x)
> +{
> + ?if (!x->j.h->e)
> + ? ?f5 (x);
> +}
> +
> +void
> +f2 (void)
> +{
> + ?f6 (f1);
> +}
> +
> +void
> +f3 (T5 x, T1 *y)
> +{
> +}
> +
> +void
> +f4 (void)
> +{
> + ?f7 (f3);
> +}
>
> ? ? ? ?Jakub
>


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