arm-none-eabi-gcc 4.9.3: local varible optimize away even if volatile added

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

arm-none-eabi-gcc 4.9.3: local varible optimize away even if volatile added

1,086 Views
vaughn
Contributor II

I post a question in KDS: variable optimized out when compile with O2 and LTO option , and the last question is that:

as a sample followed:

optimized away even if volatile added.png

when compiled with O2 and linked with LTO, the local varible addr will be optimized away even if the volatile added, maybe there has relation with the gcc's version.

I searched google, test some answer, and found no one satisfied.

0 Kudos
2 Replies

641 Views
vaughn
Contributor II

thanks Jorge.

I have try it again just like this:

int volatile addr;

addr = (int)(&__SP_INIT);

The local addr optimized.

I'm not familay with assembly, so I have not try same as your's, which defined as a pointer. It will be no effect.

The differency should be the version of arm gcc, I'm using arm-none-eabi-gcc 4.9.2, I use it for a long time, there's maybe some risk changing other version of gcc, I doubt.

Which version of gcc you are using?

0 Kudos

641 Views
jorge_a_vazquez
NXP Employee
NXP Employee

Hi

I'm using the KDS with default installation:

Release notes for
*************************************************
GNU Tools for ARM Embedded Processors 4.8

Best regards

Jorge Alcala

0 Kudos