2016-07-15 02:47 AM
2016-07-15 09:41 AM
If you use gcc, there is an
option
of compilation (-flto) you should do what you want without having to changethe code
. The option of compilation -flto, performs a blobal optimization. Below is the result (in bytes) of compilation of 3 code examples:
| p1-avr | p2-stm32f1 | p3-stm32f4 | --------|--------|------------|------------| Os | 23911 | 34180 | 75384 | Os-flto | 21015 | 11552 | 33036 | O3 | 27219 | 43708 | 93416 | O3-flto | 29813 | 13416 | 41460 | --------|--------|------------|------------|2016-07-15 03:52 PM
2016-07-18 02:03 AM
Thank you Silva for the suggestion to use Link Time Optimisation; it does actually reduce code size and increase the speed of my application. Unfortunately the disassembly of the LTO'd code removes comments and I can't verify if the 'useless' code is actually removed. And also out of curiosity, I would still like to know why removing dead code would break the code when optimised for size and work with every other optimisation level.