https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81736
Bug ID: 81736
Summary: Unnecessary save and restore frame pointer with
-fno-omit-frame-pointer
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: hjl.tools at gmail dot com
CC: ubizjak at gmail dot com
Target Milestone: ---
Target: x86-64
[hjl@gnu-4 tmp]$ cat y.i
extern int i;
int foo (void)
{
return i;
}
[hjl@gnu-4 tmp]$ gcc -S -O3 y.i -fno-omit-frame-pointer
[hjl@gnu-4 tmp]$ cat y.s
.file "y.i"
.text
.p2align 4,,15
.globl foo
.type foo, @function
foo:
.LFB0:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movl i(%rip), %eax
movq %rsp, %rbp
.cfi_def_cfa_register 6
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE0:
.size foo, .-foo
There is no need to save and restore frame pointer since stack is untouched.