From patchwork Wed Jul 14 21:55:47 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 58933 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id DE7C2B6F0E for ; Thu, 15 Jul 2010 07:55:56 +1000 (EST) Received: (qmail 21961 invoked by alias); 14 Jul 2010 21:55:54 -0000 Received: (qmail 21951 invoked by uid 22791); 14 Jul 2010 21:55:53 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mail-pv0-f175.google.com (HELO mail-pv0-f175.google.com) (74.125.83.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 14 Jul 2010 21:55:49 +0000 Received: by pvg13 with SMTP id 13so35411pvg.20 for ; Wed, 14 Jul 2010 14:55:47 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.153.8 with SMTP id a8mr7838646wfe.55.1279144547078; Wed, 14 Jul 2010 14:55:47 -0700 (PDT) Received: by 10.142.226.18 with HTTP; Wed, 14 Jul 2010 14:55:47 -0700 (PDT) In-Reply-To: References: Date: Wed, 14 Jul 2010 14:55:47 -0700 Message-ID: Subject: Re: Turn on -fomit-frame-pointer by default for 32bit x86? From: "H.J. Lu" To: Richard Guenther Cc: Andrew Pinski , GCC Patches , Uros Bizjak X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org On Wed, Jul 14, 2010 at 6:46 AM, H.J. Lu wrote: > On Wed, Jul 14, 2010 at 1:09 AM, Richard Guenther > wrote: >> On Tue, Jul 13, 2010 at 11:44 PM, H.J. Lu wrote: >>> On Tue, Jul 13, 2010 at 2:02 PM, Andrew Pinski wrote: >>>> On Tue, Jul 13, 2010 at 2:01 PM, Andrew Pinski wrote: >>>>> On Tue, Jul 13, 2010 at 1:59 PM, H.J. Lu wrote: >>>>>> What will stop working when -fomit-frame-pointer is on? >>>>> >>>>> backtraces when debugging information is not turned on. >>>> >>>> See http://gcc.gnu.org/ml/gcc-patches/2004-08/msg01033.html and many >>>> more.  This is not the first time this has been discussed. >>> >>> Most of 32bit x86 assembly codes in glibc have .eh_frame section. >>> If backtrace is absolutely needed, they can add -fasynchronous-unwind-tables >>> or -fno-omit-frame-pointer. >> >> We build opensuse with -fomit-frame-pointer -fasynchronous-unwind-tables. >> If you want to make -fomit-frame-pointer the default then you should enable >> unwind tables by default. >> > > I will try and make it target/OS dependent. > Here is a patch. How does it look? diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 4fd2aab..fe30bfd 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -2985,10 +2985,23 @@ override_options (bool main_args_p) { if (flag_zee == 2) flag_zee = 0; + /* Unwind info is not correct around the CFG unless either a + frame pointer is present or -maccumulate-outgoing-args is + set. When both -fasynchronous-unwind-tables and + -fomit-frame-pointer are turned on by default, turn off + both if -mno-accumulate-outgoing-args is used. */ if (flag_omit_frame_pointer == 2) - flag_omit_frame_pointer = 0; + flag_omit_frame_pointer + = (TARGET_SUBTARGET32_OMIT_FRAME_POINTER_DEFAULT + && (!TARGET_SUBTARGET32_ASYNCHRONOUS_UNWIND_TABLES_DEFAULT + || !(target_flags_explicit + & MASK_ACCUMULATE_OUTGOING_ARGS))); if (flag_asynchronous_unwind_tables == 2) - flag_asynchronous_unwind_tables = 0; + flag_asynchronous_unwind_tables + = (TARGET_SUBTARGET32_ASYNCHRONOUS_UNWIND_TABLES_DEFAULT + && (!TARGET_SUBTARGET32_OMIT_FRAME_POINTER_DEFAULT + || !(target_flags_explicit + & MASK_ACCUMULATE_OUTGOING_ARGS))); if (flag_pcc_struct_return == 2) flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN; } diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index eb3eb9f..c0ae95f 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -467,6 +467,8 @@ extern tree x86_mfence; /* Extra bits to force on w/ 32-bit mode. */ #define TARGET_SUBTARGET32_DEFAULT 0 #define TARGET_SUBTARGET32_ISA_DEFAULT 0 +#define TARGET_SUBTARGET32_OMIT_FRAME_POINTER_DEFAULT 0 +#define TARGET_SUBTARGET32_ASYNCHRONOUS_UNWIND_TABLES_DEFAULT 0 /* Extra bits to force on w/ 64-bit mode. */ #define TARGET_SUBTARGET64_DEFAULT 0 diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h index 81dfd1e..61d53b5 100644 --- a/gcc/config/i386/linux.h +++ b/gcc/config/i386/linux.h @@ -219,3 +219,10 @@ along with GCC; see the file COPYING3. If not see /* i386 glibc provides __stack_chk_guard in %gs:0x14. */ #define TARGET_THREAD_SSP_OFFSET 0x14 #endif + +/* Turn on -fomit-frame-pointer and -fasynchronous-unwind-tables by + default. */ +#undef TARGET_SUBTARGET32_OMIT_FRAME_POINTER_DEFAULT +#define TARGET_SUBTARGET32_OMIT_FRAME_POINTER_DEFAULT 1 +#undef TARGET_SUBTARGET32_ASYNCHRONOUS_UNWIND_TABLES_DEFAULT +#define TARGET_SUBTARGET32_ASYNCHRONOUS_UNWIND_TABLES_DEFAULT 1 diff --git a/gcc/config/i386/linux64.h b/gcc/config/i386/linux64.h index 33b4dc9..5a02205 100644 --- a/gcc/config/i386/linux64.h +++ b/gcc/config/i386/linux64.h @@ -123,3 +123,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see x86_64 glibc provides it in %fs:0x28. */ #define TARGET_THREAD_SSP_OFFSET (TARGET_64BIT ? 0x28 : 0x14) #endif + +/* Turn on -fomit-frame-pointer and -fasynchronous-unwind-tables by + default. */ +#undef TARGET_SUBTARGET32_OMIT_FRAME_POINTER_DEFAULT +#define TARGET_SUBTARGET32_OMIT_FRAME_POINTER_DEFAULT 1 +#undef TARGET_SUBTARGET32_ASYNCHRONOUS_UNWIND_TABLES_DEFAULT