Drawing the line on inline
Posted Jan 13, 2006 8:13 UTC (Fri) by
xoddam (subscriber, #2322)
In reply to:
Drawing the line on inline by giraffedata
Parent article:
Drawing the line on inline
It used to be that no-one trusted compilers to do register allocation
optimally either, but now they do (admittedly there is a canonical
algorithm for it, which AFAIK isn't the case for inlining) so the
register keyword is vestigial.
> Gcc will inline [any] function if it looks beneficial.
Only if it's in the same compilation unit -- if there's only a prototype
available, the compiler can see no code to inline.
As things stand at the moment, only functions which developers think
should be inlined are available in the API headers, and those are *all*
marked with the inline keyword -- there'd be no point putting a function
in a header if you didn't want it inlined.
unit-at-a-time optimisation is an improvement, but it falls waaay short
of whole-program optimisation. When that's available I'm sure no one
will trust the compiler -- initially.
(
Log in to post comments)