ipa-devirt.c (type_with_linkage_p, [...]): Move to ...
* ipa-devirt.c (type_with_linkage_p, type_in_anonymous_namespace_p, odr_type_p): Move to ... * ipa-utils.h (type_with_linkage_p, type_in_anonymous_namespace_p, odr_type_p): here; miscro-optimize. From-SVN: r231098
This commit is contained in:
parent
cdf66caf4f
commit
a6c5361c08
3 changed files with 93 additions and 89 deletions
|
@ -1,3 +1,10 @@
|
|||
2015-12-01 Jan Hubicka <hubicka@ucw.cz>
|
||||
|
||||
* ipa-devirt.c (type_with_linkage_p, type_in_anonymous_namespace_p,
|
||||
odr_type_p): Move to ...
|
||||
* ipa-utils.h (type_with_linkage_p, type_in_anonymous_namespace_p,
|
||||
odr_type_p): here; miscro-optimize.
|
||||
|
||||
2015-12-01 Bin Cheng <bin.cheng@arm.com>
|
||||
|
||||
PR tree-optimization/68529
|
||||
|
|
|
@ -209,93 +209,6 @@ struct GTY(()) odr_type_d
|
|||
bool rtti_broken;
|
||||
};
|
||||
|
||||
/* Return true if T is a type with linkage defined. */
|
||||
|
||||
bool
|
||||
type_with_linkage_p (const_tree t)
|
||||
{
|
||||
/* Builtin types do not define linkage, their TYPE_CONTEXT is NULL. */
|
||||
if (!TYPE_CONTEXT (t)
|
||||
|| !TYPE_NAME (t) || TREE_CODE (TYPE_NAME (t)) != TYPE_DECL
|
||||
|| !TYPE_STUB_DECL (t))
|
||||
return false;
|
||||
|
||||
/* In LTO do not get confused by non-C++ produced types or types built
|
||||
with -fno-lto-odr-type-merigng. */
|
||||
if (in_lto_p)
|
||||
{
|
||||
/* To support -fno-lto-odr-type-merigng recognize types with vtables
|
||||
to have linkage. */
|
||||
if (RECORD_OR_UNION_TYPE_P (t)
|
||||
&& TYPE_BINFO (t) && BINFO_VTABLE (TYPE_BINFO (t)))
|
||||
return true;
|
||||
/* Do not accept any other types - we do not know if they were produced
|
||||
by C++ FE. */
|
||||
if (!DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (t)))
|
||||
return false;
|
||||
}
|
||||
|
||||
return (RECORD_OR_UNION_TYPE_P (t)
|
||||
|| TREE_CODE (t) == ENUMERAL_TYPE);
|
||||
}
|
||||
|
||||
/* Return true if T is in anonymous namespace.
|
||||
This works only on those C++ types with linkage defined. */
|
||||
|
||||
bool
|
||||
type_in_anonymous_namespace_p (const_tree t)
|
||||
{
|
||||
gcc_assert (type_with_linkage_p (t));
|
||||
|
||||
/* Keep -fno-lto-odr-type-merging working by recognizing classes with vtables
|
||||
properly into anonymous namespaces. */
|
||||
if (RECORD_OR_UNION_TYPE_P (t)
|
||||
&& TYPE_BINFO (t) && BINFO_VTABLE (TYPE_BINFO (t)))
|
||||
return (TYPE_STUB_DECL (t) && !TREE_PUBLIC (TYPE_STUB_DECL (t)));
|
||||
|
||||
if (TYPE_STUB_DECL (t) && !TREE_PUBLIC (TYPE_STUB_DECL (t)))
|
||||
{
|
||||
/* C++ FE uses magic <anon> as assembler names of anonymous types.
|
||||
verify that this match with type_in_anonymous_namespace_p. */
|
||||
if (in_lto_p)
|
||||
gcc_checking_assert (!strcmp ("<anon>",
|
||||
IDENTIFIER_POINTER
|
||||
(DECL_ASSEMBLER_NAME (TYPE_NAME (t)))));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Return true of T is type with One Definition Rule info attached.
|
||||
It means that either it is anonymous type or it has assembler name
|
||||
set. */
|
||||
|
||||
bool
|
||||
odr_type_p (const_tree t)
|
||||
{
|
||||
/* We do not have this information when not in LTO, but we do not need
|
||||
to care, since it is used only for type merging. */
|
||||
gcc_checking_assert (in_lto_p || flag_lto);
|
||||
|
||||
/* To support -fno-lto-odr-type-merging consider types with vtables ODR. */
|
||||
if (type_with_linkage_p (t) && type_in_anonymous_namespace_p (t))
|
||||
return true;
|
||||
|
||||
if (TYPE_NAME (t) && TREE_CODE (TYPE_NAME (t)) == TYPE_DECL
|
||||
&& (DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (t))))
|
||||
{
|
||||
/* C++ FE uses magic <anon> as assembler names of anonymous types.
|
||||
verify that this match with type_in_anonymous_namespace_p. */
|
||||
gcc_checking_assert (!type_with_linkage_p (t)
|
||||
|| strcmp ("<anon>",
|
||||
IDENTIFIER_POINTER
|
||||
(DECL_ASSEMBLER_NAME (TYPE_NAME (t))))
|
||||
|| type_in_anonymous_namespace_p (t));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Return TRUE if all derived types of T are known and thus
|
||||
we may consider the walk of derived type complete.
|
||||
|
||||
|
|
|
@ -63,8 +63,6 @@ possible_polymorphic_call_targets (tree, HOST_WIDE_INT,
|
|||
void **cache_token = NULL,
|
||||
bool speuclative = false);
|
||||
odr_type get_odr_type (tree, bool insert = false);
|
||||
bool type_in_anonymous_namespace_p (const_tree);
|
||||
bool type_with_linkage_p (const_tree);
|
||||
bool odr_type_p (const_tree);
|
||||
bool possible_polymorphic_call_target_p (tree ref, gimple *stmt, struct cgraph_node *n);
|
||||
void dump_possible_polymorphic_call_targets (FILE *, tree, HOST_WIDE_INT,
|
||||
|
@ -176,6 +174,92 @@ polymorphic_type_binfo_p (const_tree binfo)
|
|||
return (BINFO_TYPE (binfo) && TYPE_BINFO (BINFO_TYPE (binfo))
|
||||
&& BINFO_VTABLE (TYPE_BINFO (BINFO_TYPE (binfo))));
|
||||
}
|
||||
|
||||
/* Return true if T is a type with linkage defined. */
|
||||
|
||||
inline bool
|
||||
type_with_linkage_p (const_tree t)
|
||||
{
|
||||
if (!TYPE_NAME (t) || TREE_CODE (TYPE_NAME (t)) != TYPE_DECL
|
||||
|| !TYPE_STUB_DECL (t))
|
||||
return false;
|
||||
/* In LTO do not get confused by non-C++ produced types or types built
|
||||
with -fno-lto-odr-type-merigng. */
|
||||
if (in_lto_p)
|
||||
{
|
||||
/* To support -fno-lto-odr-type-merigng recognize types with vtables
|
||||
to have linkage. */
|
||||
if (RECORD_OR_UNION_TYPE_P (t)
|
||||
&& TYPE_BINFO (t) && BINFO_VTABLE (TYPE_BINFO (t)))
|
||||
return true;
|
||||
/* With -flto-odr-type-merging C++ FE specify mangled names
|
||||
for all types with the linkage. */
|
||||
return DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (t));
|
||||
}
|
||||
|
||||
if (!RECORD_OR_UNION_TYPE_P (t) && TREE_CODE (t) != ENUMERAL_TYPE)
|
||||
return false;
|
||||
|
||||
/* Builtin types do not define linkage, their TYPE_CONTEXT is NULL. */
|
||||
if (!TYPE_CONTEXT (t))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Return true if T is in anonymous namespace.
|
||||
This works only on those C++ types with linkage defined. */
|
||||
|
||||
inline bool
|
||||
type_in_anonymous_namespace_p (const_tree t)
|
||||
{
|
||||
gcc_checking_assert (type_with_linkage_p (t));
|
||||
|
||||
if (!TREE_PUBLIC (TYPE_STUB_DECL (t)))
|
||||
{
|
||||
/* C++ FE uses magic <anon> as assembler names of anonymous types.
|
||||
verify that this match with type_in_anonymous_namespace_p. */
|
||||
gcc_checking_assert (!in_lto_p || !DECL_ASSEMBLER_NAME_SET_P (t)
|
||||
|| !strcmp
|
||||
("<anon>",
|
||||
IDENTIFIER_POINTER
|
||||
(DECL_ASSEMBLER_NAME (TYPE_NAME (t)))));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Return true of T is type with One Definition Rule info attached.
|
||||
It means that either it is anonymous type or it has assembler name
|
||||
set. */
|
||||
|
||||
inline bool
|
||||
odr_type_p (const_tree t)
|
||||
{
|
||||
/* We do not have this information when not in LTO, but we do not need
|
||||
to care, since it is used only for type merging. */
|
||||
gcc_checking_assert (in_lto_p || flag_lto);
|
||||
|
||||
if (!type_with_linkage_p (t))
|
||||
return false;
|
||||
|
||||
/* To support -fno-lto-odr-type-merging consider types with vtables ODR. */
|
||||
if (type_in_anonymous_namespace_p (t))
|
||||
return true;
|
||||
|
||||
if (TYPE_NAME (t) && TREE_CODE (TYPE_NAME (t)) == TYPE_DECL
|
||||
&& DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (t)))
|
||||
{
|
||||
/* C++ FE uses magic <anon> as assembler names of anonymous types.
|
||||
verify that this match with type_in_anonymous_namespace_p. */
|
||||
gcc_checking_assert (strcmp ("<anon>",
|
||||
IDENTIFIER_POINTER
|
||||
(DECL_ASSEMBLER_NAME (TYPE_NAME (t)))));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif /* GCC_IPA_UTILS_H */
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue