Debug versus Optimization Tradeoff
From Texas Instruments Embedded Processors Wiki
Trade-off Between Compiler Optimization and Debug
| -g Best Debug Experience |
| -g -o |
| -g -o -mn |
| -o Best Optimization |
On a sample c55 application (CGT 3.3) we observed the following: -
| Current set of options | Replaced -ss by -s | No -ms | Added -mn & -s, removed -ss | No debug at all | Debug and -o3 | |
| Debug Capabilities | OK | OK | OK | OK | None | OK |
| Build options | -ss -os -o2 -ms --symdebug:dwarf | -s -o2 -ms --symdebug:dwarf | -s -o2 --symdebug:dwarf | -s -o2 --symdebug:dwarf -mn | -s -o2 | -s -o3 --symdebug:dwarf -mn |
| Func1 | 17749 | 17749 | 17757 | 16535 | 16510 | 16489 |
| Func2 | 8482 | 8482 | 8478 | 7780 | 7770 | 7733 |
| Func3 | 45082 | 45082 | 45079 | 42276 | 42283 | 42279 |
| Func4 | 12052 | 12052 | 12046 | 10158 | 10162 | 10161 |
| Total Cycles | 83365 | 83365 | 83360 | 76749 | 76725 | 76662 |
| gain vs. current options | 0.00% | -0.01% | -7.94% | -7.96% | -8.04% |
Details on the debug experience:
| Breakpoint in ASM | Breakpoint in C | Stepping in ASM | Stepping in C | Profiling | Memory window for globals | Mixed Mode | Watch Window | |
| No debug for C, sym:dwarf for ASM only, no -mn | Yes | yes at the top of the function only. | Yes | No, no step into C | yes | yes | Yes | Issues |
| No debug for C, No debug for ASM, no -mn | Yes | yes at the top of the function only. | No | No, no step into C | Yes | yes | Yes | Issues |
| Debug for C, No debug for ASM, -mn, -s | Yes | Yes | yes | yes | Yes | yes | yes | yes |
| sym:dwarf debug for C, sym:dwarf for ASM, no -mn | Yes | Yes | yes | yes | Yes | yes | yes | yes |
| sym:dwarf debug for C, sym:dwarf for ASM, -mn, no -ms | Yes | yes | yes | yes | Yes | yes | yes | yes |
Additional Notes:
- -g and --symdebug:dwarf are equivalent.
- the long form option of -mn is --optimize_with_debug. You can use this option on any ISA including TMS470 etc.
- C5500 compiler version 3.3.2
- CCS Version 3.3
- "Issues" means the watch window does not work well. Global variables can be seen, but the window still does not refresh properly.
- -ss degrades optimization significantly.
So, starting from a base of -s -o2, adding -g degrades performance about 8%. Adding -g -mn regains nearly all of that performance while restoring the debug experience to a reasonable level.
Some comments with regard to the C6000 compiler. It does not support -mn. It presently supports a hidden option --optimize_with_debug in >= CGT 6.0.x. This option is available in production versions, but is not documented. A bug has been filed (SDSCM00020345) to this effect. The effects of -mn seen here, getting all the lost performance back, are unlikely to be the same. But this does show that customers have another point in the optimization vs. debug trade-off that is likely to be viable.
Leave a Comment