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

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

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

1,312 次查看
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 项奖励
回复
2 回复数

867 次查看
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 项奖励
回复

867 次查看
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 项奖励
回复