This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/81563] New: Callee-saved registers are restored incorrectly


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81563

            Bug ID: 81563
           Summary: Callee-saved registers are restored incorrectly
           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

[hjl@gnu-6 xxx]$ cat x.i
extern void bar (long long int, int);

long long int
fn1 (long long int x)
{
  bar (x, 1);
  return x;
}
[hjl@gnu-6 xxx]$ make
/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -O2 -Wall
-maccumulate-outgoing-args  -m32 -mincoming-stack-boundary=2
-mpreferred-stack-boundary=3 -mregparm=3 -mtune-ctrl=epilogue_using_move -S -o
x.s x.i
[hjl@gnu-6 xxx]$ cat x.s
        .file   "x.i"
        .text
        .p2align 4,,15
        .globl  fn1
        .type   fn1, @function
fn1:
.LFB0:
        .cfi_startproc
        pushl   %ebp
        .cfi_def_cfa_offset 8
        .cfi_offset 5, -8
        movl    $1, %ecx
        movl    %esp, %ebp
        .cfi_def_cfa_register 5
        pushl   %edi
        pushl   %esi
        .cfi_offset 7, -12
        .cfi_offset 6, -16
        movl    %edx, %edi
        movl    %eax, %esi
        andl    $-8, %esp
        call    bar
        movl    %esi, %eax
        movl    %edi, %edx
        movl    (%esp), %esi  <<<<<<<<< We can't restore %esi with %esp.
        movl    -4(%ebp), %edi
        leave
        .cfi_restore 5
        .cfi_restore 7
        .cfi_restore 6
        .cfi_def_cfa 4, 4
        ret
        .cfi_endproc
.LFE0:
        .size   fn1, .-fn1
        .ident  "GCC: (GNU) 8.0.0 20170726 (experimental)"
        .section        .note.GNU-stack,"",@progbits
[hjl@gnu-6 xxx]$

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]