From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26062 invoked by alias); 29 Mar 2008 08:12:09 -0000 Received: (qmail 26054 invoked by uid 22791); 29 Mar 2008 08:12:08 -0000 X-Spam-Check-By: sourceware.org Received: from rv-out-0910.google.com (HELO rv-out-0910.google.com) (209.85.198.185) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 29 Mar 2008 08:11:49 +0000 Received: by rv-out-0910.google.com with SMTP id g11so364252rvb.56 for ; Sat, 29 Mar 2008 01:11:47 -0700 (PDT) Received: by 10.140.207.3 with SMTP id e3mr2035292rvg.262.1206778307248; Sat, 29 Mar 2008 01:11:47 -0700 (PDT) Received: from ghost ( [221.218.190.195]) by mx.google.com with ESMTPS id k41sm3310626rvb.24.2008.03.29.01.11.39 (version=SSLv3 cipher=OTHER); Sat, 29 Mar 2008 01:11:46 -0700 (PDT) Date: Sat, 29 Mar 2008 08:12:00 -0000 From: "PRC" To: "gcc-help" Subject: Can I force gcc not to optimize calling to leaf functions with `-O2' option? Message-ID: <200803291611208655796@gmail.com> X-mailer: Foxmail 6, 10, 201, 20 [cn] Mime-Version: 1.0 Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: 7bit 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/msg00297.txt.bz2 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