I am deeply disappointed by the CCS compiler for MSP430! Reason is I spend the last days in resolving an issue which root cause lies in the code optimization.
The optimization level was only set to "0" - you would expect no big impact to the code. Wrong!
Already this setting creates difficulties with the generated code. See yourself, this is the code compiled with optimization turned finally OFF. On the left hand side you see the C code, right hand side the assembly code. The green highlighted instruction on line 888 is the one that will later be "optimized"
Now the optimized code, same location. I highlighted two instructions on the left hand side. On the assembly side you see that only one instruction is present. The important if condition is missing completely!
Now, taking an even closer look, the missing condition in the C code is line 888. Interestingly, the debugger can not even correlate an instruction on the assembly side to this line number. That means the system COULD detect that mistake in optimization and prevent the code from being corrupted!
Looking at the whole scenario from an other side, how safe can be a program compiled with that compiler setting? Disappearing instructions and conditions already at level 0? Wow, do we need now to scan through the assembly code before we can trust the program???
Affected versions: CCS5.5, CCS6.01, compiler TI v4.4.2, 4.3.3, device MSP430 G2553