This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Sigh. Inlining heuristics.
- To: Mark Mitchell <mark at codesourcery dot com>
- Subject: Re: Sigh. Inlining heuristics.
- From: Daniel Berlin <dan at cgsoftware dot com>
- Date: Tue, 10 Jul 2001 03:39:50 -0400
- Cc: Daniel Berlin <dan at cgsoftware dot com>,Linus Torvalds <torvalds at transmeta dot com>,"gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- References: <20740000.994747999@warlock.codesourcery.com>
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