diff options
-rw-r--r-- | gcc/ChangeLog | 13 | ||||
-rw-r--r-- | gcc/cgraphunit.c | 5 | ||||
-rw-r--r-- | gcc/ipa-devirt.c | 18 | ||||
-rw-r--r-- | gcc/ipa-icf.c | 12 | ||||
-rw-r--r-- | gcc/ipa-polymorphic-call.c | 6 | ||||
-rw-r--r-- | gcc/ipa-utils.h | 1 | ||||
-rw-r--r-- | gcc/ipa.c | 2 | ||||
-rw-r--r-- | gcc/tree.c | 10 |
8 files changed, 36 insertions, 31 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ef9b0f6ff47..33f58654417 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,18 @@ 2015-05-22 Jan Hubicka <hubicka@ucw.cz> + * ipa-utils.h (method_class_type): Remove. + * cgraphunit.c (walk_polymorphic_call_targets): Use TYPE_METHOD_BASETYPE. + * ipa-devirt.c (type_in_anonymous_namespace_p): Check that it is called + on main variants only. + (method_class_type): Remove. + (update_type_inheritance_graph): Use TYPE_METHOD_BASETYPE. + (build_type_inheritance_graph): Likewise. + * ipa-icf.c (sem_function::equals_wpa): Likewise. + * pa-polymorphic-call.c (decl_maybe_in_construction_p, + check_stmt_for_type_change): Use TYPE_METHOD_BASETYPE. + +2015-05-22 Jan Hubicka <hubicka@ucw.cz> + * tree.c (prototype_p, virtual_method_call_p, obj_type_ref_class, is_typedef_decl, typedef_variant_p): Constify. * tree.h (prototype_p, virtual_method_call_p, obj_type_ref_class, diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index 757f03d281b..8d97163cf99 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -866,9 +866,8 @@ walk_polymorphic_call_targets (hash_set<void *> *reachable_call_targets, (TREE_TYPE (targets[i]->decl)) == METHOD_TYPE && !type_in_anonymous_namespace_p - (method_class_type - (TREE_TYPE (targets[i]->decl)))) - enqueue_node (targets[i]); + (TYPE_METHOD_BASETYPE (TREE_TYPE (targets[i]->decl)))) + enqueue_node (targets[i]); } } diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c index 09c3b5b0455..77ecd0d2d83 100644 --- a/gcc/ipa-devirt.c +++ b/gcc/ipa-devirt.c @@ -2279,18 +2279,6 @@ dump_type_inheritance_graph (FILE *f) } } -/* Given method type T, return type of class it belongs to. - Look up this pointer and get its type. */ - -tree -method_class_type (const_tree t) -{ - tree first_parm_type = TREE_VALUE (TYPE_ARG_TYPES (t)); - gcc_assert (TREE_CODE (t) == METHOD_TYPE); - - return TREE_TYPE (first_parm_type); -} - /* Initialize IPA devirt and build inheritance tree graph. */ void @@ -2314,8 +2302,7 @@ build_type_inheritance_graph (void) if (is_a <cgraph_node *> (n) && DECL_VIRTUAL_P (n->decl) && n->real_symbol_p ()) - get_odr_type (TYPE_MAIN_VARIANT (method_class_type (TREE_TYPE (n->decl))), - true); + get_odr_type (TYPE_METHOD_BASETYPE (TREE_TYPE (n->decl)), true); /* Look also for virtual tables of types that do not define any methods. @@ -3446,8 +3433,7 @@ update_type_inheritance_graph (void) if (DECL_VIRTUAL_P (n->decl) && !n->definition && n->real_symbol_p ()) - get_odr_type (method_class_type (TYPE_MAIN_VARIANT (TREE_TYPE (n->decl))), - true); + get_odr_type (TYPE_METHOD_BASETYPE (TREE_TYPE (n->decl)), true); timevar_pop (TV_IPA_INHERITANCE); } diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c index e7a317ab79d..190cd4c43d9 100644 --- a/gcc/ipa-icf.c +++ b/gcc/ipa-icf.c @@ -663,8 +663,8 @@ sem_function::equals_wpa (sem_item *item, if (TREE_CODE (TREE_TYPE (item->decl)) != METHOD_TYPE) return return_false_with_msg ("DECL_CXX_CONSTURCTOR type mismatch"); else if (!func_checker::compatible_polymorphic_types_p - (method_class_type (TREE_TYPE (decl)), - method_class_type (TREE_TYPE (item->decl)), false)) + (TYPE_METHOD_BASETYPE (TREE_TYPE (decl)), + TYPE_METHOD_BASETYPE (TREE_TYPE (item->decl)), false)) return return_false_with_msg ("ctor polymorphic type mismatch"); } @@ -753,8 +753,8 @@ sem_function::equals_wpa (sem_item *item, if (TREE_CODE (TREE_TYPE (decl)) != TREE_CODE (TREE_TYPE (item->decl))) return return_false_with_msg ("METHOD_TYPE and FUNCTION_TYPE mismatch"); if (!func_checker::compatible_polymorphic_types_p - (method_class_type (TREE_TYPE (decl)), - method_class_type (TREE_TYPE (item->decl)), false)) + (TYPE_METHOD_BASETYPE (TREE_TYPE (decl)), + TYPE_METHOD_BASETYPE (TREE_TYPE (item->decl)), false)) return return_false_with_msg ("THIS pointer ODR type mismatch"); } @@ -2722,14 +2722,14 @@ sem_item_optimizer::update_hash_by_addr_refs () { if (TREE_CODE (TREE_TYPE (m_items[i]->decl)) == METHOD_TYPE && contains_polymorphic_type_p - (method_class_type (TREE_TYPE (m_items[i]->decl))) + (TYPE_METHOD_BASETYPE (TREE_TYPE (m_items[i]->decl))) && (DECL_CXX_CONSTRUCTOR_P (m_items[i]->decl) || (static_cast<sem_function *> (m_items[i])->param_used_p (0) && static_cast<sem_function *> (m_items[i]) ->compare_polymorphic_p ()))) { tree class_type - = method_class_type (TREE_TYPE (m_items[i]->decl)); + = TYPE_METHOD_BASETYPE (TREE_TYPE (m_items[i]->decl)); inchash::hash hstate (m_items[i]->hash); if (TYPE_NAME (class_type) diff --git a/gcc/ipa-polymorphic-call.c b/gcc/ipa-polymorphic-call.c index 083648d7e42..b69f54184d0 100644 --- a/gcc/ipa-polymorphic-call.c +++ b/gcc/ipa-polymorphic-call.c @@ -588,7 +588,7 @@ decl_maybe_in_construction_p (tree base, tree outer_type, block = BLOCK_SUPERCONTEXT (block)) if (tree fn = inlined_polymorphic_ctor_dtor_block_p (block, check_clones)) { - tree type = TYPE_MAIN_VARIANT (method_class_type (TREE_TYPE (fn))); + tree type = TYPE_METHOD_BASETYPE (TREE_TYPE (fn)); if (!outer_type || !types_odr_comparable (type, outer_type)) { @@ -618,7 +618,7 @@ decl_maybe_in_construction_p (tree base, tree outer_type, && !DECL_CXX_DESTRUCTOR_P (function))) return false; } - tree type = TYPE_MAIN_VARIANT (method_class_type (TREE_TYPE (function))); + tree type = TYPE_METHOD_BASETYPE (TREE_TYPE (function)); if (!outer_type || !types_odr_comparable (type, outer_type)) { if (TREE_CODE (type) == RECORD_TYPE @@ -1399,7 +1399,7 @@ check_stmt_for_type_change (ao_ref *ao ATTRIBUTE_UNUSED, tree vdef, void *data) && gimple_call_num_args (stmt)) { tree op = walk_ssa_copies (gimple_call_arg (stmt, 0)); - tree type = method_class_type (TREE_TYPE (fn)); + tree type = TYPE_METHOD_BASETYPE (TREE_TYPE (fn)); HOST_WIDE_INT offset = 0, size, max_size; if (dump_file) diff --git a/gcc/ipa-utils.h b/gcc/ipa-utils.h index 46c82dafd80..a171c564508 100644 --- a/gcc/ipa-utils.h +++ b/gcc/ipa-utils.h @@ -72,7 +72,6 @@ void dump_possible_polymorphic_call_targets (FILE *, tree, HOST_WIDE_INT, bool possible_polymorphic_call_target_p (tree, HOST_WIDE_INT, const ipa_polymorphic_call_context &, struct cgraph_node *); -tree method_class_type (const_tree); tree inlined_polymorphic_ctor_dtor_block_p (tree, bool); bool decl_maybe_in_construction_p (tree, tree, gimple, tree); tree vtable_pointer_value_to_binfo (const_tree); diff --git a/gcc/ipa.c b/gcc/ipa.c index b3752de5e1b..eb6fd41a696 100644 --- a/gcc/ipa.c +++ b/gcc/ipa.c @@ -197,7 +197,7 @@ walk_polymorphic_call_targets (hash_set<void *> *reachable_call_targets, unused. */ if (TREE_CODE (TREE_TYPE (n->decl)) == METHOD_TYPE && type_in_anonymous_namespace_p - (method_class_type (TREE_TYPE (n->decl)))) + (TYPE_METHOD_BASETYPE (TREE_TYPE (n->decl)))) continue; symtab_node *body = n->function_symbol (); diff --git a/gcc/tree.c b/gcc/tree.c index 320a343da0d..caffa59d015 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -13262,7 +13262,15 @@ verify_type (const_tree t) } } - + /* ipa-devirt makes an assumption that TYPE_METHOD_BASETYPE is always + TYPE_MAIN_VARIANT and it would be odd to add methods only to variatns + of a type. */ + if (TREE_CODE (t) == METHOD_TYPE + && TYPE_MAIN_VARIANT (TYPE_METHOD_BASETYPE (t)) != TYPE_METHOD_BASETYPE (t)) + { + error ("TYPE_METHOD_BASETYPE is not main variant"); + error_found = true; + } if (error_found) { |