You copied the Doc URL to your clipboard.

How optimization affects the debug experience

Higher optimization levels result in an increasingly degraded debug view because the mapping of object code to source code is not always clear. The compiler might perform optimizations that debug information cannot describe.

Therefore, there is a trade-off between optimizing code and the debug experience.

For good debug experience, Arm recommends -O1 rather than -O0. When using -O1, the compiler performs certain optimizations, but the structure of the generated code is still close to the source code.

For more information, see Selecting optimization options.