[PATCH] Improved folding of virtual calls (gimple and C++ review requested)

Jason Merrill jason@redhat.com
Thu Apr 22 01:40:00 GMT 2010


On 04/20/2010 07:29 AM, Martin Jambor wrote:
> When examining the BINFO structures and looking for the chain of
> virtual methods for the given actual and referenced type, I discovered
> that I have to use one out of two methods depending whether the actual
> type is derived through single or multiple inheritance.  Basically, if
> I want to find latter I need to dive deep into BINFOs representing the
> ancestors with non-zero offsets within the type and those contain the
> list I am interested in.  On the other hand, if the ancestor lies at
> the offset zero of the actual type, the BINFOs representing the
> ancestors don't have the list (actually they have one but with wrong
> values) but fortunately the indices of virtual functions are the same
> in the actual type (only that it can have more of them) so we can use
> those.  So in the end I dive deep into the binfos only when hitting
> multiple inheritance and keep the top-most binfo otherwise.

I don't really see this in the patch.  If the BINFOs have the wrong 
offsets, that sounds like a front end bug...

> +	  if (TREE_TYPE (base_binfo) != TREE_TYPE (field))

The first TREE_TYPE should be BINFO_TYPE.

Is this supposed to be testing whether CLASSTYPE_AS_BASE for the base 
class is different from the class itself?  That's the effect I would 
expect, and that's different from whether multiple inheritance is involved.

Jason



More information about the Gcc-patches mailing list