How optimization affects the debug experience
There is a trade-off between optimizing code and the debug experience.
The precise optimizations performed by the compiler depend both on the level of optimization chosen, and whether you are optimizing for performance or code size.
The lowest optimization level,
provides the best debug experience because the structure of the generated code
directly corresponds to the source code.
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 cannot be described by debug information.