> On 07/28/2009 10:44 AM, Richard Henderson wrote: > >I guess I'll poke at cleaning this up today. I've got to > >familiarize myself with how virtual clones work... > > The virtual clones that ipa-cp makes seems to be easy. > > My thought here is that since (virtual) clones don't > have actual bodies (and when they acquire bodies they > cease to be clones), then there's no reason for them > to have callee edges at all. If you want the list of > callees for a clone, you look at node->clone_of->callees. > In this way, when we materialize a clone, we don't have > to go looking for (and updating) edges, we just create > them as we copy the statements.
This is not quite true, you can take function, clone it and then clone one of callees. Now one call to callee might need to point to original, while other to the clone. To represent this and similar transforms you need different set of edges for each clone. Also the goal is to make clones appear as much as real functions as possible for the optimizations, so they don't need to deal with too many special cases. > > What I don't understand is how the inliner uses clones. > Can you explain this? We don't apply inlining decisions at the time inliner decide inline A to B. Instead inline clone A is created and B's edge to A is redirected to this clone to represent that later we will duplicate the body and inline it into the function. Also concerning your code, please note that clonning never created identical copies, we had some problems here with saving for inlining. Since we in general leave statements unfolded in various occasions and inliner folds on handling some codes, we sometimes end up rendering part of functions unreachable and removing it etc. even when not doing any non-trivial substitutions. Honza > > > r~