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: Inlining (was: GCC 3.3 release criteria)


On Tue, Feb 25, 2003 at 09:59:52AM -0800, Matt Austern wrote:

> Some programmers have the expectation that the compiler will always
> inline everything that's marked inline.  Other programmers very
> definitely do not expect that, and write code where 'inline' is
> treated merely as a hint to the compiler: marking a function
> 'inline' means you're telling the compiler that you won't mind if it
> chooses to inline the function.

In my experience, most C programmers expect inline to inline, while
C++ programmers dont.

> (Inline-as-hint is what the C++ Standard says, for what it's worth.
> I don't know the C99 standard as well.)

I'm not sure about C99 - my understanding is that the compiler is
allowed to ignore the inline keyword but most C programmers dont
expect it to.

> Empirically, treating 'inline' as a directive rather than a hint
> will make a lot of programs much worse.  This isn't conjecture.  We
> did the measurement at Apple.  -fobey-inline is occasionally useful,
> but making it the default would be disastrous.

Just to be clear: were these C programs or C++ ?

> In the end I expect that more and more compilers will choose to
> ignore the 'inline' keyword entirely.  They'll treat it the same way
> as 'register', and for the same reason: a sufficiently clever
> optimizer has more information than the programmer does, and can do
> a better job of knowing which functions should be inlined.  Some
> optimizers are already good enough so that's true.  Our optimizer
> isn't (yet), but that's where we eventually want to be.

I kinda agree that using 'register' today would be idiotic, as
compilers are pretty good at making that choice already. And I hope
gcc will get there with 'inline' as well eventually. But frankly,
today, gcc's inlining just sucks for C programmers. The inline keyword
is not as satisfying as a smart compiler heuristic might be, but it's
much nicer than what we have today.

Cheers,

-- 
Michel "Walken" LESPINASSE
Is this the best that god can do ? Then I'm not impressed.


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