> This patch changes ipa-devirt. It contains a loop checking all the member > functions are 'the same'. However, as the comment says, we've already > zapped TYPE_METHODS, so the loop is never entered. I've added equivalent > zapping in this patch series, as the rationale appears to be reducing memory > footprint. It didn't seem appropriate to merge into the TYPE_FIELDS loop, > given it's never exercised. > > I'd appreciate review. > > nathan > > -- > Nathan Sidwell
> 2017-07-14 Nathan Sidwell <nat...@acm.org> > > gcc/ > * ipa-devirt.c (odr_types_equivalent_p): Delete TYPE_METHODS scan. OK (we get virtual methods checked for match by comparing virtual tables, methods of same name are ODR checked, so we only miss diagnostics when one unit defines non-virtual method while other doesn't. It would be nice to check this, too, but there are cheaper ways of doing this) Honza > > Index: gcc/ipa-devirt.c > =================================================================== > --- gcc/ipa-devirt.c (revision 250160) > +++ gcc/ipa-devirt.c (working copy) > @@ -1602,62 +1602,6 @@ odr_types_equivalent_p (tree t1, tree t2 > > return false; > } > - if ((TYPE_MAIN_VARIANT (t1) == t1 || TYPE_MAIN_VARIANT (t2) == t2) > - && COMPLETE_TYPE_P (TYPE_MAIN_VARIANT (t1)) > - && COMPLETE_TYPE_P (TYPE_MAIN_VARIANT (t2)) > - && odr_type_p (TYPE_MAIN_VARIANT (t1)) > - && odr_type_p (TYPE_MAIN_VARIANT (t2)) > - && (TYPE_METHODS (TYPE_MAIN_VARIANT (t1)) > - != TYPE_METHODS (TYPE_MAIN_VARIANT (t2)))) > - { > - /* Currently free_lang_data sets TYPE_METHODS to error_mark_node > - if it is non-NULL so this loop will never realy execute. */ > - if (TYPE_METHODS (TYPE_MAIN_VARIANT (t1)) != error_mark_node > - && TYPE_METHODS (TYPE_MAIN_VARIANT (t2)) != error_mark_node) > - for (f1 = TYPE_METHODS (TYPE_MAIN_VARIANT (t1)), > - f2 = TYPE_METHODS (TYPE_MAIN_VARIANT (t2)); > - f1 && f2 ; f1 = DECL_CHAIN (f1), f2 = DECL_CHAIN (f2)) > - { > - if (DECL_ASSEMBLER_NAME (f1) != DECL_ASSEMBLER_NAME (f2)) > - { > - warn_odr (t1, t2, f1, f2, warn, warned, > - G_("a different method of same type " > - "is defined in another " > - "translation unit")); > - return false; > - } > - if (DECL_VIRTUAL_P (f1) != DECL_VIRTUAL_P (f2)) > - { > - warn_odr (t1, t2, f1, f2, warn, warned, > - G_("a definition that differs by virtual " > - "keyword in another translation unit")); > - return false; > - } > - if (DECL_VINDEX (f1) != DECL_VINDEX (f2)) > - { > - warn_odr (t1, t2, f1, f2, warn, warned, > - G_("virtual table layout differs " > - "in another translation unit")); > - return false; > - } > - if (odr_subtypes_equivalent_p (TREE_TYPE (f1), > - TREE_TYPE (f2), visited, > - loc1, loc2)) > - { > - warn_odr (t1, t2, f1, f2, warn, warned, > - G_("method with incompatible type is " > - "defined in another translation unit")); > - return false; > - } > - } > - if ((f1 == NULL) != (f2 == NULL)) > - { > - warn_odr (t1, t2, NULL, NULL, warn, warned, > - G_("a type with different number of methods " > - "is defined in another translation unit")); > - return false; > - } > - } > } > break; > }