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]

Re: Sigh. Inlining heuristics.


Mark Mitchell <mark@codesourcery.com> writes:

>  flag_default_inline == 1 by default (see decl2.c)
> 
> That's sort-of epxected in C++.  In C++,
> 
>   struct S { void f() {} };
> 
> implicitly declares `f' to be `inline'.  In contrast:
> 
>   struct S { void f(); };
>   void S::f() {}
> 
> does not, but `inline void S::f() {}' is exactly equivalent to the
> original version.  The standard says that the first and last versions
> are semantically identical.
> 

However, we'll still mark  it to be inlined *anyway*. Observe:

#include <stdio.h>
struct S { void f(); };
void S::f() {
printf ("blah\n");
}

int main(void)
{
        S a;
        a.f();
}
    .globl main
        .type   main,@function
main:
.LFB2:
        stwu 1,-16(1)
.LCFI2:
        mflr 3
        lis 4,stdout@ha
        stw 3,20(1)
.LCFI3:
        lis 5,.LC0@ha
        lwz 3,stdout@l(4)
        la 4,.LC0@l(5)
        crxor 6,6,6
        bl fprintf
        li 3,0
        lwz 4,20(1)
        addi 1,1,16
        mtlr 4
        blr
.LFE2:
.Lfe2:

Clearly, we inlined it, 

In fact, we currently inline it even with -fno-default-inline.

And it's being tree inlined.

So something has decided to mark it inline, since tree inlining won't
inline anything !(DECL_INLINE())


> Some people don't like this, which is what `-fno-default-inline' is
> for.  That keeps the semantics of `inline' (too hairy to talk about
> here), but does not actually allow the inlining.
> 
> That flag only affects member function, because the standard's
> implict-inlineness only applies to members defined in their
> containing class definitions.


-- 
"Friday, I was in a bookstore and I started talking to a French
looking girl.  She was a bilingual illiterate -- she couldn't
read in two different languages.
"-Steven Wright


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