Re: __attribute__((optimize("-O2"))) doesn't work

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Shouldn’t it be optimized to:

 0x0000000000400530 <+0>:	mov    $0x2,%eax
 0x0000000000400535 <+5>:	retq   

just like I compiled it with "gcc -O2 t.c”?

Anyway, I just want to say that the __attribute__((optimize(“xx”))) doesn’t seem to work. I tried to use __attribute__((optimize(0))) to turn off optimization on certain functions, but also failed.

Thanks,
Chaoran

> On Dec 22, 2014, at 3:48 PM, Oleg Endo <oleg.endo@xxxxxxxxxxx> wrote:
> 
> On Mon, 2014-12-22 at 15:43 -0600, Chaoran Yang wrote:
>> I’ve tried __attribute__((optimize(“O2”))) and __attribute__((optimize((2))). All didn’t work.
> 
> What do you expect to be optimized away in your example function?
> 
> int foo() __attribute__((optimize("O2")));
> int foo()
> {
>  return 2;
> }
> 
> Cheers,
> Oleg
> 
> 





[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux