On Thu, 2006-01-05 at 13:37 +0000, Andrew Haley wrote: > Andrew Pinski writes: > > > > On Jan 5, 2006, at 8:09 AM, Andrew Haley wrote: > > > > > I've been experimenting with devirtualizing method calls, and > > > sometimes a construct like this can pay dividends: > > > > > Another possibility is to have the inliner convert virtual calls into > > > something like the above. Maybe the real solution to all of is is to > > > have a representation for virtual calls in the IL, but... > > > > > > So, what I'm thinking of doing is writing a post-inlining pass that > > > rewrites the trees and then tidies up the CFG. Is this the right > > > approach? > > > > Just for the record, there are already two other people implementing > > something like already: > > http://gcc.gnu.org/ml/gcc-patches/2005-12/msg00487.html > > and > > http://gcc.gnu.org/ml/gcc-patches/2005-10/msg01563.html
> OK, thanks. I'll check out the IPA branch and see what's there. > Just FYI, the first link above is "real" devirtualization (IE class hierarchy analysis + transformation of a virtual call completely into a direct call). The second link above implements *exactly* what you are proposing (this isn't really devirt because it's not actually doing anything that involves determining what the method can or can't call, it's just seeing what it often happens to be calling and tries to optimize that case). > Andrew. >