summaryrefslogtreecommitdiff
path: root/gcc/ipa-devirt.c
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2018-12-22 21:06:52 +0100
committerJan Hubicka <hubicka@gcc.gnu.org>2018-12-22 20:06:52 +0000
commit4611c03d2b0edefc8d8e17872ef143428f56380b (patch)
treeae0e33447d1fbef7cf93d110ce90a633b543b633 /gcc/ipa-devirt.c
parentb5e1a724542d517b8c6861047141f8c805b6c3f9 (diff)
tree.c: (obj_type_ref_class): Move to...
* tree.c: (obj_type_ref_class): Move to... * ipa-devirt.c (obj_type_ref_class): Move to here; lookup main odr type. (get_odr_type): Compensate for type simplification. * g++.dg/ipa/devirt-30.C: Add dg-do. * g++.dg/lto/devirt-1_0.C: New testcase. * g++.dg/lto/devirt-2_0.C: New testcase. * g++.dg/lto/devirt-3_0.C: New testcase. * g++.dg/lto/devirt-4_0.C: New testcase. * g++.dg/lto/devirt-5_0.C: New testcase. * g++.dg/lto/devirt-6_0.C: New testcase. * g++.dg/lto/devirt-13_0.C: New testcase. * g++.dg/lto/devirt-14_0.C: New testcase. * g++.dg/lto/devirt-19_0.C: New testcase. * g++.dg/lto/devirt-22_0.C: New testcase. * g++.dg/lto/devirt-23_0.C: New testcase. * g++.dg/lto/devirt-30_0.C: New testcase. * g++.dg/lto/devirt-34_0.C: New testcase. From-SVN: r267359
Diffstat (limited to 'gcc/ipa-devirt.c')
-rw-r--r--gcc/ipa-devirt.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c
index 9c6e2718353..ac907aa5fd2 100644
--- a/gcc/ipa-devirt.c
+++ b/gcc/ipa-devirt.c
@@ -1985,6 +1985,30 @@ add_type_duplicate (odr_type val, tree type)
return build_bases;
}
+/* REF is OBJ_TYPE_REF, return the class the ref corresponds to. */
+
+tree
+obj_type_ref_class (const_tree ref)
+{
+ gcc_checking_assert (TREE_CODE (ref) == OBJ_TYPE_REF);
+ ref = TREE_TYPE (ref);
+ gcc_checking_assert (TREE_CODE (ref) == POINTER_TYPE);
+ ref = TREE_TYPE (ref);
+ /* We look for type THIS points to. ObjC also builds
+ OBJ_TYPE_REF with non-method calls, Their first parameter
+ ID however also corresponds to class type. */
+ gcc_checking_assert (TREE_CODE (ref) == METHOD_TYPE
+ || TREE_CODE (ref) == FUNCTION_TYPE);
+ ref = TREE_VALUE (TYPE_ARG_TYPES (ref));
+ gcc_checking_assert (TREE_CODE (ref) == POINTER_TYPE);
+ tree ret = TREE_TYPE (ref);
+ if (!in_lto_p)
+ ret = TYPE_CANONICAL (ret);
+ else
+ ret = get_odr_type (ret)->type;
+ return ret;
+}
+
/* Get ODR type hash entry for TYPE. If INSERT is true, create
possibly new entry. */
@@ -2000,6 +2024,8 @@ get_odr_type (tree type, bool insert)
int base_id = -1;
type = TYPE_MAIN_VARIANT (type);
+ if (!in_lto_p)
+ type = TYPE_CANONICAL (type);
gcc_checking_assert (can_be_name_hashed_p (type)
|| can_be_vtable_hashed_p (type));