AnsweredAssumed Answered

Compiler Optimization Problems

Question asked by baird.hal.001 on Dec 23, 2011
Latest reply on Jan 4, 2012 by mckenney.bruce
After following CJacob's 18 Dec post on Yagarto vs Raisonance problems, it is probably useful to identify known pitfalls in assuming optimized code runs the same as non-optimized code. Here is my contribution. Y'all can chime in with your experience.

Optimized code maximizes register usage for temporary storage of variables. This is OK if the compiler has knowledge of any change in a variable. But if a variable is being updated by an interrupt such as a SysTick timer, the optimized code continues using the register value, and you wonder why your processing hangs. Debugging is further complicated by believing the variables watch window. It references memory. Put up a register watch and the discrepancy is then visible.

Cheers, Hal