Optimize attribute and inlining
David Brown
david.brown@hesbynett.no
Wed Jul 25 18:25:00 GMT 2012
On 25/07/12 17:30, Richard Guenther wrote:
> On Wed, Jul 25, 2012 at 4:07 PM, Selvaraj, Senthil_Kumar
> <Senthil_Kumar.Selvaraj@atmel.com> wrote:
>> Declaring a function with __attribute__((optimize("O0")) turns off
>> inlining for the translation unit (atleast) containing the function
>> (see output at the end). Is this expected behavior?
>
> Not really. The optimize attribute processing should only affect
> flags it saves. -f[no-]inline is not meaningful per function and we
> have the noinline attribute for more proper handling.
>
> That said, I consider the optimize attribute code seriously broken
> and unmaintained (but sometimes useful for debugging - and only
> that).
>
That's a pity. It's understandable - changing optimisation levels on
different functions is always going to be problematic, since
inter-function optimisations (like inlining) are going to be difficult
to define. But sometimes it could be nice to use specific optimisations
in specific places, such as loop unrolling in a critical function while
other code is to be optimised for code size. Does "#pragma Gcc
optimize" work more reliably?
More information about the Gcc
mailing list