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]
Other format: [Raw text]

Re: [PATCH] New tests for sibling call optimisation


> This is not a very good test, since it is likely that a future version
> of gcc will optimize this to just a direct (tail)call to bar(); at that
> point, the test will continue to succeed, but will no longer be testing
> what it is supposed to be testing.
> 
> It would be better to delete the assignment "ptr = bar;"
> (and the declaration of "bar").

I removed the declaration; thank you for the comment.


> > +++ sibcall-7.c Mon Nov  4 14:48:39 2002
> > @@ -0,0 +1,22 @@
> > +/* A simple check to make sure that indirect calls to
> > +   functions which do not return are not being sibcall
> > +   optimized.
> 
> It would be helpful if the comments in this test case
> explained why such calls should not be optimized.

Have added it; thanks again.  :-)

OK, to commit?

Andi.

2002-11-04  Andreas Bauer  <baueran@in.tum.de>

	gcc.dg/sibcall-6: New test for indirect sibcalls.
	gcc.dg/sibcall-7: New test for indirect sibcalls with
	attribute `noreturn'.

--- /dev/null   Sun Jul 14 11:06:13 2002
+++ sibcall-6.c Mon Nov  4 18:45:15 2002
@@ -0,0 +1,21 @@
+/* A simple check to see whether indirect calls are
+   being sibcall optimized on targets that do support
+   this notion, i.e. have the according call patterns
+   in place.
+
+   Copyright (C) 2002 Free Software Foundation Inc.
+   Contributed by Andreas Bauer <baueran@in.tum.de>  */
+
+/* { dg-do compile { target i?86-*-* } } */
+/* { dg-options "-O2 -foptimize-sibling-calls" } */
+
+int (ptr) (int);
+
+int
+foo (f)
+     int f;
+{
+  return (*ptr)(f);
+}
+
+/* { dg-final { scan-assembler "jmp" } } */
--- /dev/null   Sun Jul 14 11:06:13 2002
+++ sibcall-7.c Mon Nov  4 19:26:17 2002
@@ -0,0 +1,25 @@
+/* A simple check to make sure that indirect calls to functions
+   which do not return are not being sibcall optimized.  The
+   problem is that sibcalls to noreturn functions would no longer
+   have an edge to the EXIT-block, which means that the code
+   intended to insert sibcall_epilogue patterns doesn't.
+   This test works only with targets that have the according call
+   patterns for indirect sibcalls in place.
+
+   Copyright (C) 2002 Free Software Foundation Inc.
+   Contributed by Andreas Bauer <baueran@in.tum.de>  */
+
+/* { dg-do compile { target i?86-*-* } } */
+/* { dg-options "-O2 -foptimize-sibling-calls" } */
+
+typedef void noretfunc (void);
+noretfunc *ptr  __attribute((noreturn));
+
+int
+foo (void)
+{
+  (*ptr) ();
+}
+
+/* { dg-final { scan-assembler-not "jmp" } } */


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