The dead code elimination optimization removes expressions that are not accessible or are not referred to. This optimization reduces size and increases execution speed.
The following table explains how to control the optimization for dead code elimination.
| Turn control this option from here... | use this setting |
|---|---|
| CodeWarrior IDE | Choose Level 1, Level 2, Level 3, or Level 4 in the OptimizationsLevel settings panel. |
| source code | #pragma opt_dead_code on | off | reset |
| command line | -opt [no]deadcode |
In the following listing, the call to func1() will never execute because the if statement that it is associated with will never be true.
void func_from(void) { if (0) { func1(); } func2(); }
Consequently, the compiler can safely eliminate the call to func1(), as shown in the following listing.
void func_to(void) { func2(); }