Comparing types at LTO time

Jan Hubicka hubicka@ucw.cz
Thu Jan 9 08:53:00 GMT 2020


> There doesn't seem to be a way to compare types at LTO time. The functions
> same_type_p and comptypes are front end only if I'm not totally confused
> (which is quite possible) and type_hash_eq doesn't seem to apply for
> structure types. Please, any advice would be welcome.

At LTO time it is bit hard to say what really is the "same type".  We
have multiple notions of equivalence:
 1) TYPE_MAIN_VARIANT (t1) == TYPE_MAIN_VARIANT (t2)
    means that both types were equal in tree merging at stream in, this
    means that their IL representaiton is identical.

    This will lead to "false" for types that are same bud did not get
    merged for various reasons. One such valid reason, for example, is
    visibility of associated virtual tables
 2) types_types_same_for_odr returns true if types are considered same
    by C++ one definition rule.  This is reliable but works only for C++
    types with names (structures and unions)
 3) same_type_for_tbaa returns true if types are equivalent for type
    based alias analysis.  It returns true in much more cases than 1
    but is too coarse if you want to do datastructure changes.

So in general this is quite hard problem (and in fact I started to play
with ODR types originally to understand it better).  I would suggest
starting with 1 if you want to rewrite types and eventually add a new
comparsion once pass does something useful.

Richard may have some extra insights.

Honza
> 
> Thanks,
> 
> Gary Oblock
> 



More information about the Gcc mailing list