This chapter describes optimizations specific to Power Architecture platforms that the CodeWarrior compiler applies to your object code.
Code merging reduces the size of object code by removing identical functions. Two or more functions are identical when their executable code is identical.
The CodeWarrior build tools can only apply this optimization to object files generated by the CodeWarrior compilers. The CodeWarrior build tools can only apply this optimization to object code translated from C and C++ source code; the tools cannot apply this optimization to object code generated from assembly files.
The code merging optimization removes all but one of a group of identical functions. Controlling code merging for all identical functions shows how to invoke this optimization for all functions. Controlling code merging for weak functions only shows how to invoke this optimization for weak functions.
| Control this option from here... | use this setting |
|---|---|
| CodeWarrior IDE | Choose All Functions from the Code Merging option of the PowerPC Linker > General panel. |
| command line | -code_merging all |
| Control this option from here... | use this setting |
|---|---|
| CodeWarrior IDE | Choose Safe Functions from the Code Merging option of the PowerPC Linker > General panel. |
| command line | -code_merging safe |
The code merging optimization will not remove an identical copy of a function if your program refers to its address. In this case, the compiler keeps this copied function but replaces its executable code with a branch instruction to the original function.
To specify that the compiler and linker must not apply code merging to a function, use this directive in your source code:
__declspec(do_not_merge) fname ;
where fname is the name of a function.
To specify to the linker how to apply code merging to functions, object files, or sections, use these directives in linker command file:
DO_NOT_MERGE
DO_NOT_MERGE_FILES
DO_NOT_MERGE_SECTIONS
AGGRESSIVE_MERGE
AGGRESSIVE_MERGE_FILES
AGGRESSIVE_MERGE_SECTIONS