This option specifies the optimization level or the details of each optimization items.
Optimization that is effective for both the object size and execution speed is done. (It is the same result as when the -Odefault option is specified).
The items that can be specified as level are shown below. |
The items that can be specified as item and value are shown below. |
If this option is specified more than once for the same item, the option specified last will be valid. |
The -Oitem items not listed in the table are not affected by the -Olevel setting.
Note that optimization through the -Olevel setting does not precisely match the optimization result obtained by specifying each -Oitem value separately. For example, when the -Odefault level is specified as -Olevel and then each -Oitem is separately set to match the corresponding item value for the -Osize level, the optimization result is not equivalent to that obtained when -Osize is specified from the beginning.
extern long x[2]; extern int y[2]; static long func1(long *a, int *b) { *a=0; *b=1; return *a; } long func2(void) { return func1(&x[0], &y[1]); } |
_func1@1: .STACK _func1@1 = 6 movw de, ax push bc pop hl clrw ax movw [de+0x02], ax movw [de], ax onew ax movw [hl], ax clrw bc ; 0 is directly assigned because a and b point to different clrw ax ; addresses. ret |
static __near int func(int x, int y, int z) { return z-x-y; } int func2(void) { return func(3,4,8); } |
.SECTION .text,TEXT _func@1: .STACK _func@1 = 4 onew ax ; 1(=8-3-4) is directly assigned. ret .SECTION .textf,TEXTF _func2: .STACK _func2 = 4 movw de, #0x0008 movw bc, #0x0004 movw ax, #0x0003 br !_func@1 |
As ps and n have different types, the value of n will not be affected by "ps = 2;". Therefore, the value used for assignment in "n = 1" is used again at (A).
(When "ps = 2;" changes the value of n, the result will be changed.)
_func: .STACK _func = 4 movw de, ax clrw ax movw bc, ax movw !LOWW(_n+0x00002), ax onew ax movw hl, ax movw !LOWW(_n), ax onew ax incw ax movw [de], ax movw ax, bc ; (A) The value used for assignment in n = 1 is used again. movw !LOWW(_x+0x00002), ax movw ax, hl ; (A) movw !LOWW(_x), ax ret |
When source-level debugging is performed using an optimized object code, take account of the following ramifications.
A variable may not be read or written at the location where that variable is referenced in the source program because an expression has been transformed (copy propagation, common subexpression recognition, etc.) due to optimization. |
Step execution may not be performed according to the source program because statements have been optimized (code sharing, elimination, rearrangement, etc.). |
There is a possibility that the variable's available range (range in which the variable can be referenced in the program) or variable's location (register or memory location) is changed due to optimization (rearrangement of statements, register allocation, etc.) of statements or variables. |
Step execution for an inline-expanded statement is performed not at the inline-expanded part but within the inline expansion source function. |