aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/ipa-prop.c
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@ucw.cz>2015-05-18 15:25:22 +0800
committerAndrew Hsieh <andrewhsieh@google.com>2015-05-26 14:21:39 +0800
commit4db4241dd512cf274d07b301215c715abfd9559f (patch)
tree8b66cda5b34d737bb14f43ec440fbd5da9e5fa1d /gcc-4.9/gcc/ipa-prop.c
parent1961df0f2c1c5f01e1e68f2db63151bcfc5aaa6f (diff)
downloadtoolchain_gcc-4db4241dd512cf274d07b301215c715abfd9559f.tar.gz
toolchain_gcc-4db4241dd512cf274d07b301215c715abfd9559f.tar.bz2
toolchain_gcc-4db4241dd512cf274d07b301215c715abfd9559f.zip
Cherry-pick r212222
BUG=19872411 2014-07-01 Jan Hubicka <hubicka@ucw.cz> * ipa-utils.h (method_class_type, vtable_pointer_value_to_binfo, vtable_pointer_value_to_vtable): Constify. (contains_polymorphic_type_p): Declare. * ipa-devirt.c (method_class_type, vtable_pointer_value_to_binfo, vtable_pointer_value_to_vtable): Constify. (contains_polymorphic_type_p): New predicate. * ipa-prop.c (ipa_set_jf_known_type): Allow types containing polymorphic types. (ipa_set_ancestor_jf): Likewise. (detect_type_change): Return false in easy cases. (compute_complex_assign_jump_func): Require type to contain polymorphic type. (compute_known_type_jump_func): Likewise. Change-Id: If4b1a919f00fb1b23c6ebce84141c04120e0e2b6
Diffstat (limited to 'gcc-4.9/gcc/ipa-prop.c')
-rw-r--r--gcc-4.9/gcc/ipa-prop.c55
1 files changed, 30 insertions, 25 deletions
diff --git a/gcc-4.9/gcc/ipa-prop.c b/gcc-4.9/gcc/ipa-prop.c
index 2ccbbdbca..adfcb0354 100644
--- a/gcc-4.9/gcc/ipa-prop.c
+++ b/gcc-4.9/gcc/ipa-prop.c
@@ -394,11 +394,10 @@ static void
ipa_set_jf_known_type (struct ipa_jump_func *jfunc, HOST_WIDE_INT offset,
tree base_type, tree component_type)
{
- gcc_assert (TREE_CODE (component_type) == RECORD_TYPE
- && TYPE_BINFO (component_type));
+ gcc_assert (contains_polymorphic_type_p (base_type)
+ && contains_polymorphic_type_p (component_type));
if (!flag_devirtualize)
return;
- gcc_assert (BINFO_VTABLE (TYPE_BINFO (component_type)));
jfunc->type = IPA_JF_KNOWN_TYPE;
jfunc->value.known_type.offset = offset,
jfunc->value.known_type.base_type = base_type;
@@ -485,10 +484,9 @@ ipa_set_ancestor_jf (struct ipa_jump_func *jfunc, HOST_WIDE_INT offset,
{
if (!flag_devirtualize)
type_preserved = false;
- gcc_assert (!type_preserved
- || (TREE_CODE (type) == RECORD_TYPE
- && TYPE_BINFO (type)
- && BINFO_VTABLE (TYPE_BINFO (type))));
+ if (!type_preserved)
+ type = NULL_TREE;
+ gcc_assert (!type_preserved || contains_polymorphic_type_p (type));
jfunc->type = IPA_JF_ANCESTOR;
jfunc->value.ancestor.formal_id = formal_id;
jfunc->value.ancestor.offset = offset;
@@ -689,15 +687,9 @@ detect_type_change (tree arg, tree base, tree comp_type, gimple call,
gcc_checking_assert (DECL_P (arg)
|| TREE_CODE (arg) == MEM_REF
|| handled_component_p (arg));
- /* Const calls cannot call virtual methods through VMT and so type changes do
- not matter. */
- if (!flag_devirtualize || !gimple_vuse (call)
- /* Be sure expected_type is polymorphic. */
- || !comp_type
- || TREE_CODE (comp_type) != RECORD_TYPE
- || !TYPE_BINFO (comp_type)
- || !BINFO_VTABLE (TYPE_BINFO (comp_type)))
- return true;
+
+ if (!flag_devirtualize)
+ return false;
/* C++ methods are not allowed to change THIS pointer unless they
are constructors or destructors. */
@@ -710,7 +702,20 @@ detect_type_change (tree arg, tree base, tree comp_type, gimple call,
&& !DECL_CXX_DESTRUCTOR_P (current_function_decl)
&& (SSA_NAME_VAR (TREE_OPERAND (base, 0))
== DECL_ARGUMENTS (current_function_decl)))
- return false;
+ {
+ gcc_assert (comp_type);
+ return false;
+ }
+
+ /* Const calls cannot call virtual methods through VMT and so type changes do
+ not matter. */
+ if (!flag_devirtualize || !gimple_vuse (call)
+ /* Be sure expected_type is polymorphic. */
+ || !comp_type
+ || TREE_CODE (comp_type) != RECORD_TYPE
+ || !TYPE_BINFO (TYPE_MAIN_VARIANT (comp_type))
+ || !BINFO_VTABLE (TYPE_BINFO (TYPE_MAIN_VARIANT (comp_type))))
+ return true;
ao_ref_init (&ao, arg);
ao.base = base;
@@ -1111,8 +1116,9 @@ compute_complex_assign_jump_func (struct ipa_node_params *info,
index = ipa_get_param_decl_index (info, SSA_NAME_VAR (ssa));
if (index >= 0 && param_type && POINTER_TYPE_P (param_type))
{
- bool type_p = !detect_type_change (op1, base, TREE_TYPE (param_type),
- call, jfunc, offset);
+ bool type_p = (contains_polymorphic_type_p (TREE_TYPE (param_type))
+ && !detect_type_change (op1, base, TREE_TYPE (param_type),
+ call, jfunc, offset));
if (type_p || jfunc->type == IPA_JF_UNKNOWN)
ipa_set_ancestor_jf (jfunc, offset,
type_p ? TREE_TYPE (param_type) : NULL, index,
@@ -1244,7 +1250,8 @@ compute_complex_ancestor_jump_func (struct ipa_node_params *info,
}
bool type_p = false;
- if (param_type && POINTER_TYPE_P (param_type))
+ if (param_type && POINTER_TYPE_P (param_type)
+ && contains_polymorphic_type_p (TREE_TYPE (param_type)))
type_p = !detect_type_change (obj, expr, TREE_TYPE (param_type),
call, jfunc, offset);
if (type_p || jfunc->type == IPA_JF_UNKNOWN)
@@ -1267,12 +1274,10 @@ compute_known_type_jump_func (tree op, struct ipa_jump_func *jfunc,
if (!flag_devirtualize
|| TREE_CODE (op) != ADDR_EXPR
- || TREE_CODE (TREE_TYPE (TREE_TYPE (op))) != RECORD_TYPE
+ || !contains_polymorphic_type_p (TREE_TYPE (TREE_TYPE (op)))
/* Be sure expected_type is polymorphic. */
|| !expected_type
- || TREE_CODE (expected_type) != RECORD_TYPE
- || !TYPE_BINFO (expected_type)
- || !BINFO_VTABLE (TYPE_BINFO (expected_type)))
+ || !contains_polymorphic_type_p (expected_type))
return;
op = TREE_OPERAND (op, 0);
@@ -1280,7 +1285,7 @@ compute_known_type_jump_func (tree op, struct ipa_jump_func *jfunc,
if (!DECL_P (base)
|| max_size == -1
|| max_size != size
- || TREE_CODE (TREE_TYPE (base)) != RECORD_TYPE
+ || !contains_polymorphic_type_p (TREE_TYPE (base))
|| is_global_var (base))
return;