Re: How to avoid code elimination

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

 



On 26/11/17 14:19, Oleg Endo wrote:
> On Sun, 2017-11-26 at 12:08 +0100, phi gcc wrote:
>> .
>> .
>> if(cond)
>> { e=e;
>> }
>> .
>> ....
>>  
>> I tried to compile with -O0 but to no joy gcc always remove my 'NOP'
>> intruction knowing better than me what I could do with it.
>>
>> Is there any other idioms I should use, may be an asm("nop") or the
>> like I guess ?
> 
> Try declaring e "volatile".
> 

"volatile" is the way to do it.  It will work regardless of optimisation
levels.

Just remember that other code can still be optimised, and moved back and
forth around the volatile access.  -O0 is, IMHO, often painful for
debugging - the code produced is too big and complicated if you like to
look at the generated assembly.  I like -O1 or -Og for debugging - it is
a better compromise of decent code but little re-ordering.





[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