Function Parameters vs. Prologue (fastcall + O1 + -fschedule-insns2)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

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 <+0>: push   %ebp
   0x0804868d <+1>: mov    $0x3,%edx
   0x08048692 <+6>: mov    %esp,%ebp
   0x08048694 <+8>: mov    $0x2,%ecx
   0x08048699 <+13>: and    $0xfffffff0,%esp
   0x0804869c <+16>: call   0x804845c <funcao>


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 <+0>: push   %ebp
   0x08048341 <+1>: mov    %esp,%ebp
   0x08048343 <+3>: and    $0xfffffff0,%esp
   0x08048346 <+6>: sub    $0x10,%esp
   0x08048349 <+9>: movl   $0x3,0x4(%esp)
   0x08048351 <+17>: movl   $0x2,(%esp)
   0x08048358 <+24>: call   0x8048450 <funcao>

... or

(gdb) disas main
Dump of assembler code for function main:
   0x0804868c <+0>: push   %ebp
   0x0804868d <+1>: mov    %esp,%ebp
   0x0804868f <+3>: and    $0xfffffff0,%esp
   0x08048692 <+6>: mov    $0x3,%edx
   0x08048697 <+11>: mov    $0x2,%ecx
   0x0804869c <+16>: call   0x804845c <funcao>

Someone knows something about the combined use of the fastcall
attribute and schedule-insns2 option? Is there an issue?

Regards.

Geyslan Gregório Bem

http://hackingbits.com
@geyslangb
br.linkedin.com/in/geyslan





[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux