]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR rtl-optimization/11304 (Wrong code production with -fomit-frame-pointer)
authorJakub Jelinek <jakub@redhat.com>
Fri, 30 Aug 2019 11:43:04 +0000 (13:43 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 30 Aug 2019 11:43:04 +0000 (13:43 +0200)
Backported from mainline
2019-02-05  Jakub Jelinek  <jakub@redhat.com>

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

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/call-1.c
gcc/testsuite/gcc.target/i386/call-2.c [new file with mode: 0644]

index 27a09c534ef865d4324ebaaa0b5bd14685cfedc4..64e78f6c276151800286830698b01b011294a5ef 100644 (file)
@@ -3,6 +3,10 @@
        Backported from mainline
        2019-02-05  Jakub Jelinek  <jakub@redhat.com>
 
+       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.
 
index bd7c569c69db95fe0e441a9e448e19de58d47b8e..a2693a315c1ac3f2d80de3faa2c9c0a7042edb3f 100644 (file)
@@ -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 (file)
index 0000000..a319368
--- /dev/null
@@ -0,0 +1,12 @@
+/* PR optimization/11304 */
+/* Originator: <manuel.serrano@sophia.inria.fr> */
+/* { 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"