4.1.2. Optimization levels and the debug view
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 compiler supports the following optimization levels:
-O0Minimum optimization. The compiler performs simple optimizations that do not impair the debug view.
When debugging is enabled, this option gives the best possible debug view.
-O1Restricted optimization.
When debugging is enabled, this option gives a generally satisfactory debug view with good code density.
-O2High optimization. This is the default optimization level.
When debugging is enabled, this option might give a less satisfactory debug view.
-O3Maximum optimization. This is the most aggressive form of optimization available. It is weighted towards your choice of -Ospace or -Otime. Specifying this option enables multifile compilation by default where multiple files are specified on the command line.
When debugging is enabled, this option typically gives a poor debug view.
Because optimization affects the mapping of object code to source code, the choice of optimization level and -Ospace/-Otime generally impacts the debug view. When debugging is enabled using --debug, explicitly specify the most appropriate optimization level using the -Onum command-line option.
The option -O0 is the best option to use if a simple debug view is needed. Selecting -O0 typically increases the size of the image by 7-15%. To reduce the size of your debug tables, use the --no_debug_macros option.
For more information see: