From patchwork Tue Jul 24 12:27:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Brown X-Patchwork-Id: 172865 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 E19902C0080 for ; Tue, 24 Jul 2012 22:27:40 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1343737661; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Date:From:CC:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=c4IsVOnLmkVmThHIxI+ljmmI8+8=; b=lwmsV5jiW17vp0V sRo0mBTnl8QDeS5cyIAzyJZWsEIozUajYc36SVhEFBOCQkjor63bG9s2FAewBfYH G+zb1dbJA1sCh3tAL8I59CPF/991alsy+EBNvwjADhl6NbaLS2r5fN1olVP/q35Z J1RQ+ymKNqP0635Oo/neaDNd6ers= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Date:From:CC:Subject:Message-ID:In-Reply-To:References:MIME-Version:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=joQCdCL5PAYpRuvwJaRhbFcNOB3iDcpXqsC+WphrramPL5aIFF3gV0sOqYu2F+ WxjWO9zoga5K8yBeFuulfkkN6SS9dfu0txZ6oSGpuHLbWb3QH399FYGQvhmra8Tc jQhIv2aZr3aAGkQ6+ju8Iq+KsHL2ddWvkflZ56/HnEzio=; Received: (qmail 12058 invoked by alias); 24 Jul 2012 12:27:34 -0000 Received: (qmail 11991 invoked by uid 22791); 24 Jul 2012 12:27:33 -0000 X-SWARE-Spam-Status: No, hits=-3.5 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_THREADED, MISSING_HEADERS, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, TW_IV X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 24 Jul 2012 12:27:18 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1SteCr-0006iA-9m from Julian_Brown@mentor.com ; Tue, 24 Jul 2012 05:27:17 -0700 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Tue, 24 Jul 2012 05:27:16 -0700 Received: from octopus (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.1.289.1; Tue, 24 Jul 2012 13:27:14 +0100 Date: Tue, 24 Jul 2012 13:27:08 +0100 From: Julian Brown CC: , , , Ye Joey Subject: Re: [PATCH, ARM] Don't pull in unwinder for 64-bit division routines Message-ID: <20120724132708.49bc2afc@octopus> In-Reply-To: <20120720111527.16dea84e@octopus> References: <20120720111527.16dea84e@octopus> MIME-Version: 1.0 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 Fri, 20 Jul 2012 11:15:27 +0100 Julian Brown wrote: > Anyway: this revised version of the patch removes the strange libgcc > Makefile-fragment changes, the equivalent of which have since been > incorporated into mainline GCC now anyway, so the patch is somewhat > more straightforward than it was previously. Joey Ye contacted me offlist and suggested that the t-divmod-ef fragment might be better integrated into t-bpabi instead. Doing that makes the patch somewhat smaller/cleaner. Minimally re-tested, looks OK. Julian ChangeLog libgcc/ * Makefile.in (LIB2_DIVMOD_EXCEPTION_FLAGS): Default to -fexceptions -fnon-call-exceptions if not defined. ($(lib2-divmod-o), $(lib2-divmod-s-o)): Use above. * config/arm/t-bpabi (LIB2_DIVMOD_EXCEPTION_FLAGS): Define. gcc/testsuite/ * gcc.target/arm/div64-unwinding.c: New test. Index: libgcc/Makefile.in =================================================================== --- libgcc/Makefile.in (revision 189807) +++ libgcc/Makefile.in (working copy) @@ -497,18 +497,24 @@ libgcc-s-objects += $(patsubst %,%_s$(ob endif endif +ifeq ($(LIB2_DIVMOD_EXCEPTION_FLAGS),) +# Provide default flags for compiling divmod functions, if they haven't been +# set already by a target-specific Makefile fragment. +LIB2_DIVMOD_EXCEPTION_FLAGS := -fexceptions -fnon-call-exceptions +endif + # Build LIB2_DIVMOD_FUNCS. lib2-divmod-o = $(patsubst %,%$(objext),$(LIB2_DIVMOD_FUNCS)) $(lib2-divmod-o): %$(objext): $(srcdir)/libgcc2.c $(gcc_compile) -DL$* -c $< \ - -fexceptions -fnon-call-exceptions $(vis_hide) + $(LIB2_DIVMOD_EXCEPTION_FLAGS) $(vis_hide) libgcc-objects += $(lib2-divmod-o) ifeq ($(enable_shared),yes) lib2-divmod-s-o = $(patsubst %,%_s$(objext),$(LIB2_DIVMOD_FUNCS)) $(lib2-divmod-s-o): %_s$(objext): $(srcdir)/libgcc2.c $(gcc_s_compile) -DL$* -c $< \ - -fexceptions -fnon-call-exceptions + $(LIB2_DIVMOD_EXCEPTION_FLAGS) libgcc-s-objects += $(lib2-divmod-s-o) endif Index: libgcc/config/arm/t-bpabi =================================================================== --- libgcc/config/arm/t-bpabi (revision 189807) +++ libgcc/config/arm/t-bpabi (working copy) @@ -13,3 +13,8 @@ LIB2ADDEH = $(srcdir)/config/arm/unwind- # Add the BPABI names. SHLIB_MAPFILES += $(srcdir)/config/arm/libgcc-bpabi.ver + +# On ARM, specifying -fnon-call-exceptions will needlessly pull in +# the unwinder in simple programs which use 64-bit division. Omitting +# the option is safe. +LIB2_DIVMOD_EXCEPTION_FLAGS := -fexceptions Index: gcc/testsuite/gcc.target/arm/div64-unwinding.c =================================================================== --- gcc/testsuite/gcc.target/arm/div64-unwinding.c (revision 0) +++ gcc/testsuite/gcc.target/arm/div64-unwinding.c (revision 0) @@ -0,0 +1,24 @@ +/* Performing a 64-bit division should not pull in the unwinder. */ + +/* { dg-do run } */ +/* { dg-options "-O0" } */ + +#include + +long long +foo (long long c, long long d) +{ + return c/d; +} + +long long x = 0; +long long y = 1; + +extern int (*_Unwind_RaiseException) (void *) __attribute__((weak)); + +int main(void) +{ + if (&_Unwind_RaiseException != NULL) + abort ();; + return foo (x, y); +}