This option performs inter-module optimization.
[Specification format]
- | Interpretation when omitted |
Inter-module optimization is not performed.
[Detailed description]
- | This option performs inter-module optimization. |
- | The main optimization contents are shown below. |
- | Optimization using inter-procedural alias analysis |
The example of the output code is shown below.
[C source]
extern int x[2];
static int func1(int *a, int *b) {
*a=0;
*b=1;
return *a;
}
int func2() {
return func1(&x[0], &x[1]);
}
[Output assembler source]
_func1.1:
.stack _func1.1 = 0
mov #_x, r2
st.w r0, 0x00000000[r2]
mov 0x00000001, r5
st.w r5, 0x00000004[r2]
mov 0x00000000, r10 ; 0 is directly assigned because a and b point to different addresses.
jmp [r31]
_func2:
.stack _func2 = 0
mov #_x, r6
addi 0x00000004, r6, r7
br9 _func1.1
|
- | Constant propagation of parameters and return values |
The example of the output code is shown below.
[C source]
static int func(int x, int y, int z) {
return x-y+z;
}
int func2() {
return func(3,4,5);
}
[Output assembler source]
_func.1:
.stack _func.1 = 0
mov 0x00000000, r10 ; "4(=3-4+5)" is assigned directly.
jmp [r31]
_func2:
.stack _func2 = 0
mov 0x00000005, r8
mov 0x00000004, r7
mov 0x00000003, r6
br9 _func.1
|
[Example of use]
- | To perform inter-module optimization on source files "main.c" and "sub.c", describe as: |
>ccrh -Xintermodule -Osize -Xcommon=rh850 main.c sub.c
|