From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13037 invoked by alias); 29 Mar 2008 14:24:48 -0000 Received: (qmail 13029 invoked by uid 22791); 29 Mar 2008 14:24:47 -0000 X-Spam-Check-By: sourceware.org Received: from Unknown (HELO vms173005pub.verizon.net) (206.46.173.5) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 29 Mar 2008 14:24:25 +0000 Received: from [192.168.1.5] ([96.233.42.40]) by vms173005.mailsrvcs.net (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTPA id <0JYH004MOX364I60@vms173005.mailsrvcs.net> for gcc-help@gcc.gnu.org; Sat, 29 Mar 2008 09:18:43 -0500 (CDT) Date: Sat, 29 Mar 2008 14:24:00 -0000 From: John Fine Subject: Re: Can I force gcc not to optimize calling to leaf functions with `-O2' option? In-reply-to: <200803291611208655796@gmail.com> To: PRC Cc: gcc-help Message-id: <47EE510C.5070407@verizon.net> MIME-version: 1.0 Content-type: text/plain; charset=GB2312 Content-transfer-encoding: 7bit References: <200803291611208655796@gmail.com> User-Agent: Mozilla-Thunderbird 2.0.0.6 (X11/20071113) X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2008-03/txt/msg00299.txt.bz2 The optimization you described is called a "function tail merge". You can disable that optimization without disabling the rest of -O2. I forget the exact switch, but I expect a search for "tail merge" would find it. PRC wrote: > Hi All, > I wonder if I can inform gcc not to optimize calling to leaf functions. > > For example > ------------------- > void say_hello() > { > printf("Hello\n"); > } > void func() > { > say_hello(); > } > > > with -O2 option, gcc will optimize > jal say_hello > ... > jr ra > ... > to > j say_hello > > This is not what I want in some case. The start of the function can be located > by searching `addiu sp, XXXX' instruction, and the end of the function by > searching `jr ra', beginning with EPC when expctions arise, if all function calls > have their own exits. By this way, I can trace down the calling frames. But this > optimization breaks the rule and will confused the tracer. And the `-O2' option > is neccessary since some bugs are only exposed on `-O2'. > > Is there an approach for this purpose? > > Best Regards > PRC > Mar 29, 2008 > > >