diff options
author | Jan Hubicka <hubicka@ucw.cz> | 2015-05-18 15:25:22 +0800 |
---|---|---|
committer | Andrew Hsieh <andrewhsieh@google.com> | 2015-05-26 14:21:39 +0800 |
commit | 4db4241dd512cf274d07b301215c715abfd9559f (patch) | |
tree | 8b66cda5b34d737bb14f43ec440fbd5da9e5fa1d /gcc-4.9/gcc/ipa-devirt.c | |
parent | 1961df0f2c1c5f01e1e68f2db63151bcfc5aaa6f (diff) | |
download | toolchain_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-devirt.c')
-rw-r--r-- | gcc-4.9/gcc/ipa-devirt.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/gcc-4.9/gcc/ipa-devirt.c b/gcc-4.9/gcc/ipa-devirt.c index 0671a8b78..43e904ce7 100644 --- a/gcc-4.9/gcc/ipa-devirt.c +++ b/gcc-4.9/gcc/ipa-devirt.c @@ -534,7 +534,7 @@ dump_type_inheritance_graph (FILE *f) Lookup this pointer and get its type. */ tree -method_class_type (tree t) +method_class_type (const_tree t) { tree first_parm_type = TREE_VALUE (TYPE_ARG_TYPES (t)); gcc_assert (TREE_CODE (t) == METHOD_TYPE); @@ -887,6 +887,31 @@ devirt_node_removal_hook (struct cgraph_node *n, void *d ATTRIBUTE_UNUSED) free_polymorphic_call_targets_hash (); } +/* Return true when TYPE contains an polymorphic type and thus is interesting + for devirtualization machinery. */ + +bool +contains_polymorphic_type_p (const_tree type) +{ + type = TYPE_MAIN_VARIANT (type); + + if (RECORD_OR_UNION_TYPE_P (type)) + { + if (TYPE_BINFO (type) + && polymorphic_type_binfo_p (TYPE_BINFO (type))) + return true; + for (tree fld = TYPE_FIELDS (type); fld; fld = DECL_CHAIN (fld)) + if (TREE_CODE (fld) == FIELD_DECL + && !DECL_ARTIFICIAL (fld) + && contains_polymorphic_type_p (TREE_TYPE (fld))) + return true; + return false; + } + if (TREE_CODE (type) == ARRAY_TYPE) + return contains_polymorphic_type_p (TREE_TYPE (type)); + return false; +} + /* CONTEXT->OUTER_TYPE is a type of memory object where object of EXPECTED_TYPE is contained at CONTEXT->OFFSET. Walk the memory representation of CONTEXT->OUTER_TYPE and find the outermost class type that match @@ -1048,7 +1073,8 @@ subbinfo_with_vtable_at_offset (tree binfo, unsigned HOST_WIDE_INT offset, Return false if T does not look like virtual table reference. */ bool -vtable_pointer_value_to_vtable (tree t, tree *v, unsigned HOST_WIDE_INT *offset) +vtable_pointer_value_to_vtable (const_tree t, tree *v, + unsigned HOST_WIDE_INT *offset) { /* We expect &MEM[(void *)&virtual_table + 16B]. We obtain object's BINFO from the context of the virtual table. @@ -1094,7 +1120,7 @@ vtable_pointer_value_to_vtable (tree t, tree *v, unsigned HOST_WIDE_INT *offset) instance type. */ tree -vtable_pointer_value_to_binfo (tree t) +vtable_pointer_value_to_binfo (const_tree t) { tree vtable; unsigned HOST_WIDE_INT offset; |