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
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.
void set_eax(int val)
{
- __asm__ __volatile__ ("mov %0, %%eax" : : "m" (val));
+ __asm__ __volatile__ ("mov %0, %%eax" : : "m" (val) : "eax");
}
void foo(int val)
--- /dev/null
+/* 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"