ipa-utils.h (method_class_type): Remove.

* 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.

From-SVN: r223629
This commit is contained in:
Jan Hubicka 2015-05-24 08:13:44 +02:00 committed by Jan Hubicka
parent 66f0bbd50c
commit 70e7f2a2df
8 changed files with 36 additions and 31 deletions

View File

@ -1,3 +1,16 @@
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,

View File

@ -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]);
}
}

View File

@ -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);
}

View File

@ -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)

View File

@ -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)

View File

@ -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);

View File

@ -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 ();

View File

@ -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)
{