[RFC/patch] Callgraph based inlining heuristics
Jan Hubicka
jh@suse.cz
Mon Jun 23 18:40:00 GMT 2003
> On Mon, Jun 23, 2003 at 06:53:40PM +0200, Jan Hubicka wrote:
> > > On Mon, 23 Jun 2003, Jan Hubicka wrote:
> > >
> > > > > Btw. - are you currently maintaining an explicit callgraph, so we can
> > > > > stick notes to its edges?
> > > > Yes.
> > >
> > > So in principle we can walk "down" the cfg of a leaf function marking all
> > > edges as to be inlined?
> >
> > This has the transitivity problem. If your leaf function A calls B that
> > calls C, you mark flag "inline C into B" that may not be what you want
> > in other places you call B.
>
> This can be a problem when constant-folding makes a big difference.
>
> int C(int arg1, int arg2) {
> if (arg1 == 0)
> return arg2;
> else {
> ... massive code blob here ...
> }
> }
>
> int B(int arg1, arg2) {
> int tmp = C(arg1, arg2);
> if (arg2 > 0) {
> ... lots of code ...
> tmp = something;
> }
> return tmp;
> }
>
> int A() {
> return B(0, 0);
> }
>
> int D() {
> return B(2, 2);
> }
>
> Here, for A, inlining everything gives
>
> int A() {
> return 0;
> }
>
> But for D, both C and B will have large code blocks so we won't want to
> inline them.
Yes, however this is far more complicated case I want current inlining
heuristics to consider. One can probably reach it by doing
intraprocedural spartial constant propagation and looking on what
function collapse and when but this is not easy to implement. Once
tree-SSA is here we can play with such ideas, but not right now,
unforutnately.
Honza
>
More information about the Gcc
mailing list