Generating symbolic debugging information no longer affects the ability to optimize code. The same executable code is generated regardless of whether generation of debug information is turned on or off. For this reason, debug information is now generated by default. You do not need to specify the -g option in order to debug your application.
If you do not specify the -g option and allow the default generation of debug information to be used, the default level of optimization is used unless you specify some other optimization level.
The --symdebug:dwarf option no longer disables optimization, because generation of debug information no longer impacts optimization.
If you specify the -g option explicitly but do not specify an optimization level, no optimization is performed. This is because while generating debug information does not affect the ability to optimize code, optimizing code does make it more difficult to debug code. At higher levels of optimization, the compiler's extensive rearrangement of code and the many-to-many allocation of variables to registers often make it difficult to correlate source code with object code for debugging purposes. It is recommended that you perform debugging using the lowest level of optimization possible.
If you specify an --opt_level (aliased as -O) option, that optimization level is used no matter what type of debugging information you enabled.
The optimization level used if you do not specify the level on the command line is affected by whether or not the command line includes the -g option and the --opt_level option as shown in the following table:
Optimization | no -g | -g |
---|---|---|
no --opt_level | --opt_level=off | --opt_level=off |
--opt_level | --opt_level=2 | --opt_level=2 |
--opt_level=n | optimized as specified | optimized as specified |
Debug information increases the size of object files, but it does not affect the size of code or data on the target. If object file size is a concern and debugging is not needed, use --symdebug:none to disable the generation of debug information.
If you are having trouble debugging loops in your code, you can use the --disable_software_pipeline option to turn off software pipelining. See Section 4.6.1 for more information.