This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: struct-reorg optimization
- From: Olga Golovanevsky <OLGA at il dot ibm dot com>
- To: Jan Hubicka <jh at suse dot cz>
- Cc: Peter Bergner <bergner at us dot ibm dot com>, Daniel Berlin <dberlin at dberlin dot org>, Diego Novillo <dnovillo at google dot com>, gcc-patches at gcc dot gnu dot org, Jan Hubicka <hubicka at ucw dot cz>, Jan Hubicka <jh at suse dot cz>, Kenneth Zadeck <zadeck at naturalbridge dot com>
- Date: Sun, 26 Aug 2007 18:17:33 +0300
- Subject: Re: struct-reorg optimization
Jan Hubicka <jh@suse.cz> wrote on 25/08/2007 12:57:55:
> >
> > >
> > > name1 = get_type_name (type1);
> > > name2 = get_type_name (type2);
> > >
> > > if (name1 && name2 && !strcmp (name1, name2))
> > > return true;
> > >
> > > if (name1 && name2 && strcmp (name1, name2))
> > > return false;
> > >
> > > What happens if the two units declare type with same name and
completely
> > > different layout and use it for different variables?
> > > (ie in completely legal way). Will we every get into this matching
> > > predicate?
We are not getting here with the type names in this case, because we
are comparing TYPE_MAIN_VARIANTs, which keep no names.
> >
> > We have two corner cases here: structs with the same name and different
> > bodies,
> > and structs with same body and different names. So I think
theoretically
> > structs are equal if they have the same name and the same body. But we
cut
> > the name in many cases (like in TYPE_MAIN_VARIAN), so there is no good
> > solution
> > for now.
>
> Hmm, OK. Will tricking same name to different structures cause
> miscompilations or somethign?
It looks like the error happens only if these types really conflict.
For example, if str_t is defined differently in unit1.c
and unit2.c and there is a function foo (str_t) defined in unit2.c
and called from unit1.c, then compiler detects conflicting type
for foo () when running with -combine:
unit2.c:14: error: conflicting types for âfooâ
unit1.c:11: error: previous declaration of âfooâ was here
(I suppose it happens during building cgraph).
Otherwise they successfully coexist, i.e. each unit uses its own type.
Olga