This is the mail archive of the gcc-patches@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]

[testcase] asm clobbering %ebp with -fomit-frame-pointer


Hi!

Is this a valid test or not?
Documentation sais for -fomit-frame-pointer:
     Don't keep the frame pointer in a register for functions that
     don't need one.  This avoids the instructions to save, set up and
     restore frame pointers; it also makes an extra register available
     in many functions.
so I'm not sure if clobbering of %ebp is valid at all.

2001-10-29  Jakub Jelinek  <jakub@redhat.com>

	* gcc.dg/20011029-1.c: New test.

--- gcc/testsuite/gcc.dg/20011029-1.c.jj	Mon Oct 29 11:42:42 2001
+++ gcc/testsuite/gcc.dg/20011029-1.c	Mon Oct 29 11:41:44 2001
@@ -0,0 +1,46 @@
+/* { dg-do run { target i?86-*-linux* } } */
+/* { dg-options "-O2 -fomit-frame-pointer" } */
+
+extern void abort (void);
+extern void exit (int);
+
+static void foo (unsigned long long *ret)
+{
+  static unsigned long long x = 24;
+
+  *ret = x;
+  x += 12;
+}
+
+static void bar (unsigned long long x)
+{
+  static int cnt;
+
+  if (x != 12)
+    abort ();
+  if (cnt++ == 8)
+    exit (0);
+}
+
+int baz (void)
+{
+  for (;;)
+    {
+      unsigned long long d1, d2;
+      int i;
+      foo (&d1);
+      for (i = 0; i < 4; i++)
+	__asm__ __volatile__ ("movl %%esp, %%ebp"
+			      : : : "eax", "ecx", "edx", "esi", "edi",
+				    "ebp", "flags");
+      foo (&d2);
+      bar (d2 - d1);
+    }
+
+  return 0;
+}
+
+int main (void)
+{
+  return baz ();
+}

	Jakub


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