$ cat tail.c
#include <stdio.h>
void foo() {
rand(9);
}
int main() {
foo();
}
$ gcc -S -O3 tail.c; cat tail.s
.file "tail.c"
.text
.p2align 4,,15
.globl _foo
.def _foo; .scl 2; .type 32; .endef
_foo:
pushl %ebp
movl %esp, %ebp
subl $8, %esp
movl $9, (%esp)
call _rand
leave
ret
.def ___main; .scl 2; .type 32; .endef
.p2align 4,,15
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
pushl %ebp
movl $16, %eax
movl %esp, %ebp
subl $8, %esp
andl $-16, %esp
call __alloca
call ___main
movl $9, (%esp) <—- foo inlined no stack frame created for call
call _rand <—-
leave
ret
.def _rand; .scl 3; .type 32; .endef
$ gcc -S -O2 tail.c; cat tail.s
.file "tail.c"
.text
.p2align 4,,15
.globl _foo
.def _foo; .scl 2; .type 32; .endef
_foo:
pushl %ebp
movl %esp, %ebp
subl $8, %esp
movl $9, (%esp)
call _rand
leave
ret
.def ___main; .scl 2; .type 32; .endef
.p2align 4,,15
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
pushl %ebp
movl $16, %eax
movl %esp, %ebp
subl $8, %esp
andl $-16, %esp
call __alloca
call ___main
call _foo <—- foo not inlined
leave
ret
.def _rand; .scl 3; .type 32; .en
Quoted from Tyche's log for Murk++. The function is called in several places in Merc and derived code. Is this something that's no longer required or does Murk++ just not need it anymore?