This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC/patch] Callgraph based inlining heuristics


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]