From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18037 invoked by alias); 4 Nov 2002 08:21:04 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 17990 invoked from network); 4 Nov 2002 08:21:02 -0000 Received: from unknown (HELO cts04.webone.com.au) (210.9.240.37) by sources.redhat.com with SMTP; 4 Nov 2002 08:21:02 -0000 Received: from kennel (dyn-ctb-210-9-246-6.webone.com.au [210.9.246.6]) by cts04.webone.com.au (8.11.6/8.11.6) with ESMTP id gA48Kw703803; Mon, 4 Nov 2002 19:20:58 +1100 Received: by kennel (Postfix, from userid 1000) id 83DEDE043; Mon, 4 Nov 2002 19:31:54 +1100 (EST) Date: Mon, 04 Nov 2002 00:21:00 -0000 From: Andreas Bauer To: Fergus Henderson Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] New tests for sibling call optimisation Message-ID: <20021104083154.GB895@kennel> References: <20021104040248.GA895@kennel> <20021104043935.GA7200@mars.cs.mu.oz.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20021104043935.GA7200@mars.cs.mu.oz.au> User-Agent: Mutt/1.3.28i X-SW-Source: 2002-11/txt/msg00156.txt.bz2 > 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 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 */ + +/* { 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 */ + +/* { 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" } } */