This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] New tests for sibling call optimisation
> I'd much rather you tested this in some machine independant way,
> so that all that is needed for new architectures is to add them
> to the target list.
>
> Hint: use __builtin_return_address(0).
I did not know about the function before. But, here is an updated
version of the test. Hope it can be used by people and be applied
now.
> > gcc.dg/sibcall-7: New test for indirect sibcalls with
> > attribute `noreturn'.
>
> This is pointless. The restriction is partly due to a
> representation problem in the compiler. The only thing
> that we ought to be verifying is that we don't ICE and
> don't generate incorrect code.
OK, will skip the test then. Personally, I found it useful while
extending the sibcall optimisation on x86 platforms, but I respect
your intention to not test a compiler shortcoming; we rather test
compiler features.
Thanks for feedback.
Looking forward to further comments,
Andi.
2002-11-04 Andreas Bauer <baueran@in.tum.de>
* gcc.dg/sibcall-6: New test for indirect sibcalls.
--- /dev/null Sun Jul 14 11:06:13 2002
+++ sibcall-6.c Tue Nov 5 11:03:03 2002
@@ -0,0 +1,42 @@
+/* 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 run { target i?86-*-* x86_64-*-*} } */
+/* { dg-options "-O2 -foptimize-sibling-calls" } */
+
+int foo (int);
+int bar (int);
+
+int (*ptr) (int);
+int *f_addr;
+
+int
+main ()
+{
+ ptr = bar;
+ foo (7);
+ exit (0);
+}
+
+int
+bar (b)
+ int b;
+{
+ if (f_addr == (int*) __builtin_return_address (0))
+ return b;
+ else
+ abort ();
+}
+
+int
+foo (f)
+ int f;
+{
+ f_addr = (int*) __builtin_return_address (0);
+ return (*ptr)(f);
+}