Commit 7d8adcba by Jan Hubicka Committed by Jan Hubicka

ipa-devirt.c (odr_types_equivalent_p): Fix formating.


	* ipa-devirt.c (odr_types_equivalent_p): Fix formating.
	(add_type_duplicate): Fix comparison of BINFOs.

From-SVN: r220546
parent 62c7e4b7
2015-02-08 Jan Hubicka <hubicka@ucw.cz> 2015-02-08 Jan Hubicka <hubicka@ucw.cz>
* ipa-devirt.c (odr_types_equivalent_p): Fix formating.
(add_type_duplicate): Fix comparison of BINFOs.
2015-02-08 Jan Hubicka <hubicka@ucw.cz>
* ipa-polymorphic-call.c (ipa_polymorphic_call_context): Avoid ICE * ipa-polymorphic-call.c (ipa_polymorphic_call_context): Avoid ICE
on getting VOID pointer. on getting VOID pointer.
......
...@@ -807,7 +807,8 @@ warn_types_mismatch (tree t1, tree t2) ...@@ -807,7 +807,8 @@ warn_types_mismatch (tree t1, tree t2)
gimple_canonical_types_compatible_p. */ gimple_canonical_types_compatible_p. */
static bool static bool
odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned, hash_set<type_pair,pair_traits> *visited) odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
hash_set<type_pair,pair_traits> *visited)
{ {
/* Check first for the obvious case of pointer identity. */ /* Check first for the obvious case of pointer identity. */
if (t1 == t2) if (t1 == t2)
...@@ -1206,8 +1207,8 @@ add_type_duplicate (odr_type val, tree type) ...@@ -1206,8 +1207,8 @@ add_type_duplicate (odr_type val, tree type)
val->types_set = new hash_set<tree>; val->types_set = new hash_set<tree>;
/* Always prefer complete type to be the leader. */ /* Always prefer complete type to be the leader. */
if (!COMPLETE_TYPE_P (val->type) if ((!COMPLETE_TYPE_P (val->type) || !TYPE_BINFO (val->type))
&& COMPLETE_TYPE_P (type)) && (COMPLETE_TYPE_P (type) && TYPE_BINFO (val->type)))
{ {
tree tmp = type; tree tmp = type;
...@@ -1229,7 +1230,8 @@ add_type_duplicate (odr_type val, tree type) ...@@ -1229,7 +1230,8 @@ add_type_duplicate (odr_type val, tree type)
vec_safe_push (val->types, type); vec_safe_push (val->types, type);
/* First we compare memory layout. */ /* First we compare memory layout. */
if (!odr_types_equivalent_p (val->type, type, !flag_ltrans && !val->odr_violated, if (!odr_types_equivalent_p (val->type, type,
!flag_ltrans && !val->odr_violated,
&warned, &visited)) &warned, &visited))
{ {
merge = false; merge = false;
...@@ -1253,31 +1255,105 @@ add_type_duplicate (odr_type val, tree type) ...@@ -1253,31 +1255,105 @@ add_type_duplicate (odr_type val, tree type)
&& TREE_CODE (type) == RECORD_TYPE && TREE_CODE (type) == RECORD_TYPE
&& TYPE_BINFO (val->type) && TYPE_BINFO (type)) && TYPE_BINFO (val->type) && TYPE_BINFO (type))
{ {
for (j = 0, i = 0; i < BINFO_N_BASE_BINFOS (TYPE_BINFO (type)); i++) if (BINFO_N_BASE_BINFOS (TYPE_BINFO (type))
if (polymorphic_type_binfo_p (BINFO_BASE_BINFO (TYPE_BINFO (type), i))) != BINFO_N_BASE_BINFOS (TYPE_BINFO (val->type)))
{
if (!warned && !val->odr_violated)
{
tree extra_base;
warn_odr (type, val->type, NULL, NULL, !warned, &warned,
"a type with the same name but different "
"number of polymorphic bases is "
"defined in another translation unit");
if (BINFO_N_BASE_BINFOS (TYPE_BINFO (type))
> BINFO_N_BASE_BINFOS (TYPE_BINFO (val->type)))
extra_base = BINFO_BASE_BINFO
(TYPE_BINFO (type),
BINFO_N_BASE_BINFOS (TYPE_BINFO (val->type)));
else
extra_base = BINFO_BASE_BINFO
(TYPE_BINFO (val->type),
BINFO_N_BASE_BINFOS (TYPE_BINFO (type)));
inform (DECL_SOURCE_LOCATION
(TYPE_NAME (DECL_CONTEXT (extra_base))),
"the extra base is defined here ");
}
base_mismatch = true;
}
else
for (i = 0; i < BINFO_N_BASE_BINFOS (TYPE_BINFO (type)); i++)
{ {
odr_type base = get_odr_type tree base1 = BINFO_BASE_BINFO (TYPE_BINFO (type), i);
(BINFO_TYPE tree base2 = BINFO_BASE_BINFO (TYPE_BINFO (val->type), i);
(BINFO_BASE_BINFO (TYPE_BINFO (type), tree type1 = BINFO_TYPE (base1);
i)), tree type2 = BINFO_TYPE (base2);
true);
if (val->bases.length () <= j || val->bases[j] != base) if (types_odr_comparable (type1, type2))
base_mismatch = true; {
j++; if (!types_same_for_odr (type1, type2))
base_mismatch = true;
}
else
{
hash_set<type_pair,pair_traits> visited;
if (!odr_types_equivalent_p (type1, type2, false, NULL,
&visited))
base_mismatch = true;
}
if (base_mismatch)
{
if (!warned && !val->odr_violated)
warn_odr (type, val->type, NULL, NULL,
!warned, &warned,
"a type with the same name but different base "
"type is defined in another translation unit");
warn_types_mismatch (type1, type2);
break;
}
if (BINFO_OFFSET (base1) != BINFO_OFFSET (base2))
{
base_mismatch = true;
if (!warned && !val->odr_violated)
warn_odr (type, val->type, NULL, NULL,
!warned, &warned,
"a type with the same name but different base "
"layout is defined in another translation unit");
break;
}
} }
/* Sanity check that all bases will be build same way again. */
if (!base_mismatch && val->bases.length ())
{
unsigned int num_poly_bases = 0;
for (i = 0; i < BINFO_N_BASE_BINFOS (TYPE_BINFO (type)); i++)
if (polymorphic_type_binfo_p (BINFO_BASE_BINFO
(TYPE_BINFO (type), i)))
num_poly_bases++;
gcc_assert (num_poly_bases == val->bases.length ());
for (j = 0, i = 0; i < BINFO_N_BASE_BINFOS (TYPE_BINFO (type));
i++)
if (polymorphic_type_binfo_p (BINFO_BASE_BINFO
(TYPE_BINFO (type), i)))
{
odr_type base = get_odr_type
(BINFO_TYPE
(BINFO_BASE_BINFO (TYPE_BINFO (type),
i)),
true);
gcc_assert (val->bases[j] == base);
j++;
}
}
if (base_mismatch) if (base_mismatch)
{ {
merge = false; merge = false;
odr_violation_reported = true; odr_violation_reported = true;
if (!warned && !val->odr_violated)
warn_odr (type, val->type, NULL, NULL, !warned, &warned,
"a type with the same name but different bases is "
"defined in another translation unit");
val->odr_violated = true; val->odr_violated = true;
if (symtab->dump_file) if (symtab->dump_file)
{ {
fprintf (symtab->dump_file, "ODR bse violation or merging bug?\n"); fprintf (symtab->dump_file, "ODR base violation\n");
print_node (symtab->dump_file, "", val->type, 0); print_node (symtab->dump_file, "", val->type, 0);
putc ('\n',symtab->dump_file); putc ('\n',symtab->dump_file);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment