广告
广告
Chapter 19
Power Architecture Optimizations
This chapter describes optimizations specific to Power Architecture platforms that the
CodeWarrior compiler applies to your object code:
•
19.1 Code Merging
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.
Tip
For example, the C++ compiler often generates several copies of the same function when it instantiates template functions.
These functions have different names, and these names are considered weak . Under normal circumstances, the linker will issue an error message if it encounters duplicate names. But the linker ignores duplicate names that are marked as weak.
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
Freescale Semiconductor, Inc.
329
Code Merging
The code merging optimization removes all but one of a group of identical functions.
Table 19-1 shows how to invoke this optimization for all functions. Table 19-2 shows how to invoke this optimization for weak functions.
Table 19-1. Controlling code merging for all identical functions
Control this option from here...
CodeWarrior IDE command line
use this setting
Choose
All Functions from the Code Merging option of the
PowerPC Linker > General panel.
-code_merging all command line
Table 19-2. Controlling code merging for weak functions only
Control this option from here...
CodeWarrior IDE
use this setting
Choose Safe Functions from the Code Merging option of the
PowerPC Linker > General panel.
-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
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
330 Freescale Semiconductor, Inc.
广告