Compiler Optimizations

Has anyone used the compiler optimizations? If so, which have you used? and have you had any problems with them?

I recently ran out of space on the controller, I rewrote quite a bit of code to optimize it, i got rid of all the unnecessary stuff and continued coding. I then ran out of space again. There is very little that i can do to compact my code even further, so i decided to try the compiler optimizations. I managed to get a significant improvement in size, from 99% to 89%, but i was wondering if there is anything i should be aware of, as i have not yet tested the new code on a robot. Is there anything that the compiler does in optimizations that might mess stuff up?

For FIRST purposes, optimizations don’t really present any special problems unless you are doing special things like debugging inline assembly.

if you enable all the compiler optimizations, make sure that anything volatile is declared volatile explicitly. You can get away without it with no optimizations (at least some times), but not with all the optimizations enabled.

I fought that at least a few times this weekend.

If you are running short of data space (RAM) be sure to declare the command_list array in commands.h as “rom”.

Probably a good idea even if you’re not short on RAM, since it will take up space in FLASH regardless of whether it’s declared “rom” or not.