From: Jakub Jelinek Date: Fri, 30 Aug 2019 11:43:04 +0000 (+0200) Subject: backport: re PR rtl-optimization/11304 (Wrong code production with -fomit-frame-pointer) X-Git-Tag: releases/gcc-7.5.0~260 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ddb4546b6150827b3d4c25a56ca665dac39d404b;p=thirdparty%2Fgcc.git backport: re PR rtl-optimization/11304 (Wrong code production with -fomit-frame-pointer) Backported from mainline 2019-02-05 Jakub Jelinek PR rtl-optimization/11304 * gcc.target/i386/call-1.c (set_eax): Add "eax" clobber. * gcc.target/i386/call-2.c: New test. From-SVN: r275102 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 27a09c534ef8..64e78f6c2761 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -3,6 +3,10 @@ Backported from mainline 2019-02-05 Jakub Jelinek + PR rtl-optimization/11304 + * gcc.target/i386/call-1.c (set_eax): Add "eax" clobber. + * gcc.target/i386/call-2.c: New test. + PR target/89188 * g++.dg/opt/pr89188.C: New test. diff --git a/gcc/testsuite/gcc.target/i386/call-1.c b/gcc/testsuite/gcc.target/i386/call-1.c index bd7c569c69db..a2693a315c1a 100644 --- a/gcc/testsuite/gcc.target/i386/call-1.c +++ b/gcc/testsuite/gcc.target/i386/call-1.c @@ -11,7 +11,7 @@ volatile int r; void set_eax(int val) { - __asm__ __volatile__ ("mov %0, %%eax" : : "m" (val)); + __asm__ __volatile__ ("mov %0, %%eax" : : "m" (val) : "eax"); } void foo(int val) diff --git a/gcc/testsuite/gcc.target/i386/call-2.c b/gcc/testsuite/gcc.target/i386/call-2.c new file mode 100644 index 000000000000..a31936854c95 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/call-2.c @@ -0,0 +1,12 @@ +/* PR optimization/11304 */ +/* Originator: */ +/* { dg-do run } */ +/* { dg-options "-O -fomit-frame-pointer" } */ + +/* Verify that %eax is always restored after a call. */ + +__attribute__((noinline, noclone)) void set_eax(int val); +__attribute__((noinline, noclone)) void foo(int val); +__attribute__((noinline, noclone)) int bar(int x); + +#include "call-1.c"