This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/58252] [4.9 Regression] ice in gimple_get_virt_method_for_binfo with -O2


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58252

--- Comment #7 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
Bad news that the experimental fixes I added to PR58585 and the PR that depends
on it does not seem to completely solve this issue.

Here with the offset compensation we die while calling get_binfo_at_offset with
offset -384 looking for _impl_Container within StructDef.  Here we walk down
the chain


impl_Container
    |
StructDef
    |
impl_StructDef

impl_Container has offset of 384 within impl_StructDef and there seems to be no
vtables on the way with the updated check for vtables using FLAG_2.
If we can share vtables in such case it would seem to make sense to set offset
to 384 and thus perhaps just ingore the other case where we have multiple
inheritance and we are visiting same base for second time. Does the thunk
depends on way we arrive to it? 
Index: ipa-devirt.c
===================================================================
--- ipa-devirt.c        (revision 205941)
+++ ipa-devirt.c        (working copy)
@@ -646,8 +646,17 @@

   if (types_same_for_odr (type, outer_type))
     {
-      tree inner_binfo = get_binfo_at_offset (type_binfo,
-                                             offset, otr_type);
+      /* In the case of multiple inheritance it is possible that we already
+        visited given type by earlier class sharing same base.  In this case
+        we do not need to look into this branch.  */
+      if (tree_to_uhwi (BINFO_OFFSET (binfo))
+         < tree_to_uhwi (BINFO_OFFSET (type_binfo)))
+       return;
+      tree inner_binfo = get_binfo_at_offset
+                         (type_binfo, offset
+                          + (tree_to_uhwi (BINFO_OFFSET (binfo))
+                             - tree_to_uhwi (BINFO_OFFSET (type_binfo)))
+                          * BITS_PER_UNIT, otr_type);
       /* For types in anonymous namespace first check if the respective vtable
         is alive. If not, we know the type can't be called.  */
       if (!flag_ltrans && anonymous)
@@ -679,7 +688,7 @@
                                /* In the case of single inheritance,
                                   the virtual table is shared with
                                   the outer type.  */
-                               BINFO_VTABLE (base_binfo) ? base_binfo :
type_binfo,
+                               BINFO_FLAG_2 (base_binfo) && BINFO_VTABLE
(base_binfo) ? base_binfo : type_binfo,
                                otr_token, outer_type, offset, inserted,
                                matched_vtables, anonymous);
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]