Hi,

PR 57084 has alerted me that IN LTO we do not devirtualize calls
during ipa-cp and ipa-inline that we do in non-LTO compilations.  The
reason is that the type comparison in get_binfo_at_offset is failing,
because the two types do not have the same TYPE_MAIN_VARIANT but
TYPE_CANONICAL should be checked instead.  Or better yet, call
types_compatible_p which hopefully will also know what to do in these
cases, which is what the patch below does.

The change increases the number of type-based devirtualizations in
ipa-cp and ipa-inline from 137 to 179 in 483.xalancbmk when compiles
with -O2 -flto -m32 (-m32 is not significant here, it was only
required to trigger the bug and I made the measurements in the same
environment).

Bootstrapped and tested on x86_64-linux without any issues.  OK for
trunk?

Thanks,

Martin


2013-05-10  Martin Jambor  <mjam...@suse.cz>

        * tree.c (get_binfo_at_offset): Use types_compatible_p to compare
        types.

Index: src/gcc/tree.c
===================================================================
--- src.orig/gcc/tree.c
+++ src/gcc/tree.c
@@ -11483,7 +11483,7 @@ get_binfo_at_offset (tree binfo, HOST_WI
       tree fld;
       int i;
 
-      if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (expected_type))
+      if (types_compatible_p (type, expected_type))
          return binfo;
       if (offset < 0)
        return NULL_TREE;

Reply via email to