This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] New tests for sibling call optimisation
- From: Andreas Bauer <baueran at in dot tum dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 4 Nov 2002 15:02:49 +1100
- Subject: [PATCH] New tests for sibling call optimisation
Hi All,
For my personal use, I have added two further tests to the existing
sibcall tests created by Hans-Peter Nilsson. The two add-ons are checking
whether targets that are capable of optimising indirect calls are doing the
right thing, especially when the callee contains an attribute `noreturn'.
The tests are not huge, but have been useful to me in the past (and may be
useful to others, especially now that x86_64 is becoming capable of doing
indirect sibcalls as well). I hope you include them to 3.4 bib, or let me
know if there's a problem with them, so I can fix it.
Looking forward to your feedback,
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 14:48:12 2002
@@ -0,0 +1,23 @@
+/* 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);
+extern int bar (int);
+
+int
+foo (f)
+ int f;
+{
+ ptr = bar;
+ return (*ptr)(f);
+}
+
+/* { dg-final { scan-assembler "jmp" } } */
--- /dev/null Sun Jul 14 11:06:13 2002
+++ 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. Works only on 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 noreturnfunc (void);
+noreturnfunc *ptr __attribute((noreturn));
+
+int
+foo (void)
+{
+ (*ptr) ();
+}
+
+/* { dg-final { scan-assembler-not "jmp" } } */