I'm curious about what is causing this reordering (prologue with the function parameters):
# gcc structs.c -o structs -m32 -O1 -fschedule-insns2
(gdb) disas main
Dump of assembler code for function main:
0x0804868c : push %ebp
0x0804868d : mov $0x3,%edx
0x08048692 : mov %esp,%ebp
0x08048694 : mov $0x2,%ecx
0x08048699 : and $0xfffffff0,%esp
0x0804869c : call 0x804845c
The code:
__attribute__((fastcall)) void funcao(int i, int a) {
...
int main() {
int i, a;
i = 2;
i = 3;
funcao(i, a);
...
When I remove one of them (fastcall or schedule-insns2), the binary is generated in logic order:
(gdb) disas main
Dump of assembler code for function main:
0x08048340 : push %ebp
0x08048341 : mov %esp,%ebp
0x08048343 : and $0xfffffff0,%esp
0x08048346 : sub $0x10,%esp
0x08048349 : movl $0x3,0x4(%esp)
0x08048351 : movl $0x2,(%esp)
0x08048358 : call 0x8048450
... or
(gdb) disas main
Dump of assembler code for function main:
0x0804868c : push %ebp
0x0804868d : mov %esp,%ebp
0x0804868f : and $0xfffffff0,%esp
0x08048692 : mov $0x3,%edx
0x08048697 : mov $0x2,%ecx
0x0804869c : call 0x804845c
Someone knows something about the combined use of the fastcall attribute and schedule-insns2 option? Is there an issue?