[RFC/patch] Callgraph based inlining heuristics

Joe Buck jbuck@synopsys.com
Mon Jun 23 18:11: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.



More information about the Gcc mailing list