https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85078

--- Comment #4 from rguenther at suse dot de <rguenther at suse dot de> ---
On Fri, 6 Apr 2018, jakub at gcc dot gnu.org wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85078
> 
> Jakub Jelinek <jakub at gcc dot gnu.org> changed:
> 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>                  CC|                            |jakub at gcc dot gnu.org
> 
> --- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
> (In reply to Richard Biener from comment #2)
> > --- tree.c      (revision 258851)
> > +++ tree.c      (working copy)
> > @@ -5522,6 +5522,8 @@ find_decls_types_r (tree *tp, int *ws, v
> >           FOR_EACH_VEC_ELT (*BINFO_BASE_BINFOS (TYPE_BINFO (t)), i, tem)
> >             fld_worklist_push (TREE_TYPE (tem), fld);
> >           fld_worklist_push (BINFO_VIRTUALS (TYPE_BINFO (t)), fld);
> > +         fld_worklist_push (BINFO_TYPE (tem), fld);
> > +         fld_worklist_push (BINFO_VTABLE (tem), fld);
> 
> I don't see how this can work, tem should be NULL here, as it is outside of 
> the
> FOR_EACH_VEC_ELT loop.  That said, I don't really see the b class ever
> appearing here, t is just i and g, nothing else.

Sorry, the patch pasted was bogus, my final attempts were the following
but it seems devirt has some fancy way to reach to other classes.
Honza, can you please look at this?  Otherwise I'll revert the offending
change.

Index: tree.c
===================================================================
--- tree.c      (revision 259082)
+++ tree.c      (working copy)
@@ -5520,8 +5520,14 @@ find_decls_types_r (tree *tp, int *ws, v
          unsigned i;
          tree tem;
          FOR_EACH_VEC_ELT (*BINFO_BASE_BINFOS (TYPE_BINFO (t)), i, tem)
-           fld_worklist_push (TREE_TYPE (tem), fld);
+           {
+             fld_worklist_push (BINFO_TYPE (tem), fld);
+             fld_worklist_push (BINFO_VIRTUALS (tem), fld);
+             fld_worklist_push (BINFO_VTABLE (TYPE_BINFO (tem)), fld);
+           }
          fld_worklist_push (BINFO_VIRTUALS (TYPE_BINFO (t)), fld);
+         fld_worklist_push (BINFO_TYPE (TYPE_BINFO (t)), fld);
+         fld_worklist_push (BINFO_VTABLE (TYPE_BINFO (t)), fld);
        }
       if (RECORD_OR_UNION_TYPE_P (t))
        {
@@ -5700,7 +5706,11 @@ find_decls_types_in_node (struct cgraph_
          gimple *stmt = gsi_stmt (si);

          if (is_gimple_call (stmt))
-           find_decls_types (gimple_call_fntype (stmt), fld);
+           {
+             find_decls_types (gimple_call_fntype (stmt), fld);
+             if (virtual_method_call_p (gimple_call_fn (stmt)))
+               find_decls_types (obj_type_ref_class (gimple_call_fn 
(stmt)), fld);
+           }

          for (i = 0; i < gimple_num_ops (stmt); i++)
            {

Reply via email to