This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Prevend duplicate SFTs for structs in structs in structs.
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 25 Jul 2005 15:56:07 +0200 (CEST)
- Subject: [PATCH] Prevend duplicate SFTs for structs in structs in structs.
Fixes the testcase for which we currently decompose like
;; Function foo (foo)
structure field tag SFT.0 created for var a offset 32 size 32
structure field tag SFT.1 created for var a offset 0 size 64
structure field tag SFT.2 created for var a offset 0 size 32
foo ()
{
ugh. Maybe even not harmless.
Bootstrapped and tested on x86_64-unknown-linux-gnu. Ok for mainline?
Thanks,
Richard.
2005-07-25 Richard Guenther <rguenther@suse.de>
* tree-ssa-structalias.c (push_fields_onto_fieldstack):
Avoid pushing again if current struct contains only
fields we decomposed.
* gcc.dg/tree-ssa/salias-1.c: New testcase.
*** tree-ssa-structalias.c.orig 2005-07-25 15:43:18.727468383 +0200
--- tree-ssa-structalias.c 2005-07-25 15:44:44.285566621 +0200
*************** push_fields_onto_fieldstack (tree type,
*** 2972,2977 ****
--- 2972,2978 ----
if (TREE_CODE (field) == FIELD_DECL)
{
bool push = false;
+ int pushed = 0;
if (has_union
&& (TREE_CODE (TREE_TYPE (field)) == QUAL_UNION_TYPE
*************** push_fields_onto_fieldstack (tree type,
*** 2980,2986 ****
if (!var_can_have_subvars (field))
push = true;
! else if (!(push_fields_onto_fieldstack
(TREE_TYPE (field), fieldstack,
offset + bitpos_of_field (field), has_union))
&& DECL_SIZE (field)
--- 2981,2987 ----
if (!var_can_have_subvars (field))
push = true;
! else if (!(pushed = push_fields_onto_fieldstack
(TREE_TYPE (field), fieldstack,
offset + bitpos_of_field (field), has_union))
&& DECL_SIZE (field)
*************** push_fields_onto_fieldstack (tree type,
*** 2999,3004 ****
--- 3000,3007 ----
pair->offset = offset + bitpos_of_field (field);
count++;
}
+ else
+ count += pushed;
}
return count;
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-salias" } */
struct {
struct {
struct {
int i, j;
} c;
} b;
} a;
int foo(void)
{
a.b.c.i = 0;
return a.b.c.j;
}
/* { dg-final { scan-tree-dump-times "SFT" 2 "salias" } } */
/* { dg-final { cleanup-tree-dump "salias" } } */