Bug ID: 81736
           Summary: Unnecessary save and restore frame pointer with
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot
          Reporter: 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"
        .p2align 4,,15
        .globl  foo
        .type   foo, @function
        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
        .size   foo, .-foo

There is no need to save and restore frame pointer since stack is untouched.

Reply via email to