* 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
+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,
(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]);
}
}
}
}
-/* 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
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.
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);
}
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");
}
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");
}
{
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)
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))
{
&& !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
&& 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)
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);
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 ();
}
}
-
+ /* 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)
{