This fixes PR54898, we can't disregard comparing or hashing TYPE_MAIN_VARIANT when we rely on intact variant relationships.
LTO bootstrapped on x86_64-unknown-linux-gnu, testing in progress. Richard. 2012-10-12 Richard Biener <rguent...@suse.de> PR lto/54898 * lto.c (gimple_types_compatible_p_1): Also compare TYPE_MAIN_VARIANT. (iterative_hash_gimple_type): Also hash TYPE_MAIN_VARIANT. Index: gcc/lto/lto.c =================================================================== *** gcc/lto/lto.c (revision 192392) --- gcc/lto/lto.c (working copy) *************** gimple_types_compatible_p_1 (tree t1, tr *** 581,586 **** --- 581,595 ---- if (!compare_type_names_p (t1, t2)) goto different_types; + /* The main variant of both types should compare equal. */ + if (TYPE_MAIN_VARIANT (t1) != t1 + || TYPE_MAIN_VARIANT (t2) != t2) + { + if (!gtc_visit (TYPE_MAIN_VARIANT (t1), TYPE_MAIN_VARIANT (t2), + state, sccstack, sccstate, sccstate_obstack)) + goto different_types; + } + /* We may not merge typedef types to the same type in different contexts. */ if (TYPE_NAME (t1) *************** iterative_hash_gimple_type (tree type, h *** 1101,1106 **** --- 1110,1121 ---- && TYPE_P (DECL_CONTEXT (TYPE_NAME (type)))) v = visit (DECL_CONTEXT (TYPE_NAME (type)), state, v, sccstack, sccstate, sccstate_obstack); + + /* Factor in the variant structure. */ + if (TYPE_MAIN_VARIANT (type) != type) + v = visit (TYPE_MAIN_VARIANT (type), state, v, + sccstack, sccstate, sccstate_obstack); + v = iterative_hash_hashval_t (TREE_CODE (type), v); v = iterative_hash_hashval_t (TYPE_QUALS (type), v); v = iterative_hash_hashval_t (TREE_ADDRESSABLE (type), v);