When some arguments of a function should be placed on a stack (see Sections 3.3.3 and 3.3.4 of MSP430 EABI for example), LLVM generates correct but inefficient instruction sequences inside a calling function. Consider the following program based on examples from EABI:
void f(int x, long y, long z);
void g(int x, long long y);
extern int i;
extern long j, k;
extern long long ll;
void call_f(void) {
f(i, j, k);
}
void call_g(void) {
g(i, ll);
}
When compiled with GCC with -Os -S options, it produces (with non-instruction lines omitted):
When some arguments of a function should be placed on a stack (see Sections 3.3.3 and 3.3.4 of MSP430 EABI for example), LLVM generates correct but inefficient instruction sequences inside a calling function. Consider the following program based on examples from EABI:
When compiled with GCC with
-Os -S
options, it produces (with non-instruction lines omitted):And LLVM:
Disassembly for GCC:
And for LLVM:
That is,
addr -> r11
+r11 -> 6(r1)
takes 2*4 bytes whileaddr -> 6(r1)
takes 6 bytes only.