This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/60996] New: Bad code (I.e. needless insns) with option momit-leaf-frame-pointer; side-effect on non-leaf functions
- From: "meisenmann dot lba at fh-salzburg dot ac dot at" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 29 Apr 2014 07:12:53 +0000
- Subject: [Bug target/60996] New: Bad code (I.e. needless insns) with option momit-leaf-frame-pointer; side-effect on non-leaf functions
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60996
Bug ID: 60996
Summary: Bad code (I.e. needless insns) with option
momit-leaf-frame-pointer; side-effect on non-leaf
functions
Product: gcc
Version: 4.8.2
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: meisenmann.lba@fh-salzburg.ac.at
Using the option '-momit-leaf-frame-pointer' (with -fno-omit-frame-pointer) has
a side-effect on non-leaf functions. The code-snippets afterwards (produced
with an i386-elf cross-compiler for an IA32-target) will show the difference:
A) Without the option momit-leaf-frame-pointer:
Example1:
pushl %ebp
movl %esp, %ebp
pushl %ebx
subl $8, %esp
movl (%eax), %ebx
pushl 12(%ebp)
pushl 8(%ebp)
pushl %ecx
pushl %edx
pushl %eax
call *12(%ebx)
movl -4(%ebp), %ebx
leave
ret
B) Option '-momit-leaf-frame-pointer' used:
Example1:
pushl %ebp
movl %esp, %ebp
pushl %ebx
subl $8, %esp
movl (%eax), %ebx
pushl 12(%ebp)
pushl 8(%ebp)
pushl %ecx
pushl %edx
pushl %eax
call *12(%ebx)
addl $24, %esp
movl -4(%ebp), %ebx
leave
ret
In this case there'a an additional stack-adjustment (addl $24, %esp) before the
"final" stack-leave instruction. Some other examples with less forwarded
call-arguments have shown a few pop-insn instead of an 'add'.
These additional instruction(s) directly before reverting the stack-frame has
no functional effect, but will consume a few CPU-cycles.