re PR ipa/65270 (issues with merging memory accesses from different code paths)

PR ipa/65270
	* ipa-icf.c (sem_item::compare_cgraph_references): Compare
	vtable references for their containing type.
	(sem_function::equals_wpa): Compare TYPE_RESTRICT
	and type attributes.

From-SVN: r221199
This commit is contained in:
Jan Hubicka 2015-03-05 01:10:29 +01:00 committed by Jan Hubicka
parent d10a61fbe8
commit fe75bd2069
2 changed files with 30 additions and 0 deletions

View File

@ -1,3 +1,11 @@
2015-03-03 Jan Hubicka <hubicka@ucw.cz>
PR ipa/65270
* ipa-icf.c (sem_item::compare_cgraph_references): Compare
vtable references for their containing type.
(sem_function::equals_wpa): Compare TYPE_RESTRICT
and type attributes.
2015-03-04 Eric Botcazou <ebotcazou@adacore.com>
* fold-const.c (round_up_loc): Cast divisor to signed on all paths

View File

@ -345,6 +345,20 @@ sem_item::compare_cgraph_references (
{
enum availability avail1, avail2;
if (n1 == n2)
return true;
/* Merging two definitions with a reference to equivalent vtables, but
belonging to a different type may result in ipa-polymorphic-call analysis
giving a wrong answer about the dynamic type of instance. */
if (is_a <varpool_node *> (n1)
&& (DECL_VIRTUAL_P (n1->decl) || DECL_VIRTUAL_P (n2->decl))
&& (DECL_VIRTUAL_P (n1->decl) != DECL_VIRTUAL_P (n2->decl)
|| !types_must_be_same_for_odr (DECL_CONTEXT (n1->decl),
DECL_CONTEXT (n2->decl))))
return return_false_with_msg
("references to virtual tables can not be merged");
if (address && n1->equal_address_to (n2) == 1)
return true;
if (!address && n1->semantically_equivalent_p (n2))
@ -407,6 +421,10 @@ sem_function::equals_wpa (sem_item *item,
m_compared_func->arg_types[i],
is_not_leaf, i == 0))
return return_false_with_msg ("argument type is different");
if (POINTER_TYPE_P (arg_types[i])
&& (TYPE_RESTRICT (arg_types[i])
!= TYPE_RESTRICT (m_compared_func->arg_types[i])))
return return_false_with_msg ("argument restrict flag mismatch");
}
/* Result type checking. */
@ -417,6 +435,10 @@ sem_function::equals_wpa (sem_item *item,
if (node->num_references () != item->node->num_references ())
return return_false_with_msg ("different number of references");
if (comp_type_attributes (TREE_TYPE (decl),
TREE_TYPE (item->decl)) != 1)
return return_false_with_msg ("different type attributes");
ipa_ref *ref = NULL, *ref2 = NULL;
for (unsigned i = 0; node->iterate_reference (i, ref); i++)
{