> > This patch fixes the latest 58678 testcase by avoiding speculative
> > devirtualization to the destructor of an abstract class, which can
> > never succeed: you can't create an object of an abstract class, so
> > the pointer must point to an object of a derived class, and the
> > derived class necessarily has its own destructor.  Other virtual
> > member functions of an abstract class are OK for devirtualization:
> > the destructor is the only virtual function that is always
> > overridden in every class.]
> > 
> > We could also detect an abstract class by searching through the
> > vtable for __cxa_pure_virtual, but I figured it was easy enough for
> > the front end to set a flag on the BINFO.
> > 
> > Tested x86_64-pc-linux-gnu.  OK for trunk?
> 
> > commit b64f52066f3f4cdc9d5a30e2d48aaf6dd5efd3d4
> > Author: Jason Merrill <ja...@redhat.com>
> > Date:   Wed Mar 5 11:35:07 2014 -0500
> > 
> >             PR c++/58678
> >     gcc/
> >             * tree.h (BINFO_ABSTRACT_P): New.
> >             * ipa-devirt.c (abstract_class_dtor_p): New.
> >             (likely_target_p): Check it.
> 
> I think the abstract classes probably shuld never be considered in the type
> inheritance graph walk as possible instances. That is we probably want to test
> them in record_targets_from_bases, possible_polymorphic_call_targets and
> record_target_from_binfo and simply never call maybe_record_node when the type
> considered is abstract without concluding that list is incomplete as we do 
> when
> method can not be referred.  If the type has derivations that do not override
> something, we will record the methods when walking derrived type, so i do not
> think we need to make difference in between destructor and other type.
> 
> We also want to sanity check that after get_class_context the outer_type
> is not abstract or maybe_derived_type is set. 
> >     gcc/cp/
> >             * search.c (get_pure_virtuals): Set BINFO_ABSTRACT_P.
> >             * tree.c (copy_binfo): Copy it.
> 
> You need to also save and restre the flag in LTO streaming.
> 
> I can prepare patch tomorrow if you preffer, thanks for looking into this!

BTW it would conserve little bit of memory & streaming if we also stripped 
DECL_INITIAL
of those vtables. They should never be needed. (We still need DECL_VTABLE to be 
able to
work out ODR equivalence, since the types must be in type inheritance tree)

Honza

Reply via email to