From patchwork Sat Aug 25 21:31:12 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 179988 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 063212C00EB for ; Sun, 26 Aug 2012 07:31:32 +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=1346535093; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:In-Reply-To:References:Date: Message-ID:Subject:From:To:Cc:Content-Type:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=qfOFEFX6r8Y8CHEZV84VOrkOPFI=; b=rHAYEAHzCNnJn8ryeQmDbjswPW68KVbwKLTNbt/9urdotkfVkMvINbjf/3nk42 4yXRiR47ltGFmVUZzZwAE4mSUcAUUICTiEjrmXf3GqoOeteB+ea3kXy6t/QLvnVu eMp7lZdGDfC8Pv0EQ16dXK3cegUkKxRifIEOFOR4qxa1k= 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:MIME-Version:Received:Received:In-Reply-To:References:Date:Message-ID:Subject:From:To:Cc:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=xP3/sApD0kqz+CyXGtoZIVccGG1AfSBk8oRV4UehwciAwwm2FIzLekCvIPKg6p PMS8KarJQ35Nzvkg+zNRHzSU8TrRjDW856VSx/rSpACDpq6fAcKgXhrPMDb+vUM0 hrqI12u8JCpmb4V8Ghxqe1GJhU1V5eF6lob8naGwX5byk=; Received: (qmail 14178 invoked by alias); 25 Aug 2012 21:31:28 -0000 Received: (qmail 14168 invoked by uid 22791); 25 Aug 2012 21:31:27 -0000 X-SWARE-Spam-Status: No, hits=-4.9 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, KHOP_THREADED, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, TW_PD X-Spam-Check-By: sourceware.org Received: from mail-we0-f175.google.com (HELO mail-we0-f175.google.com) (74.125.82.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 25 Aug 2012 21:31:13 +0000 Received: by weyr6 with SMTP id r6so1765161wey.20 for ; Sat, 25 Aug 2012 14:31:12 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.243.1 with SMTP id j1mr4311464wer.29.1345930272333; Sat, 25 Aug 2012 14:31:12 -0700 (PDT) Received: by 10.216.2.4 with HTTP; Sat, 25 Aug 2012 14:31:12 -0700 (PDT) In-Reply-To: <5038F4A8.5040103@codesourcery.com> References: <5032EAAA.2070703@codesourcery.com> <87boi456zv.fsf@talisman.home> <50359228.3070308@codesourcery.com> <8762874j8g.fsf@talisman.home> <5038F4A8.5040103@codesourcery.com> Date: Sat, 25 Aug 2012 14:31:12 -0700 Message-ID: Subject: Re: [PATCH, MIPS] fix MIPS16 jump table overflow From: Andrew Pinski To: Sandra Loosemore Cc: gcc-patches@gcc.gnu.org, rdsandiford@googlemail.com 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 Sat, Aug 25, 2012 at 8:52 AM, Sandra Loosemore wrote: > On 08/24/2012 11:46 PM, Richard Sandiford wrote: >> >> Andrew Pinski writes: >>> >>> On Fri, Aug 24, 2012 at 10:08 PM, Andrew Pinski >>> wrote: >>>> >>>> On Wed, Aug 22, 2012 at 7:15 PM, Sandra Loosemore >>>> wrote: >>>>> >>>>> On 08/21/2012 02:23 PM, Richard Sandiford wrote: >>>>>> >>>>>> >>>>>> >>>>>> Would be nice to add a compile test for -mabi=64 just to make sure >>>>>> that Pmode == DImode works. A copy of an existing test like >>>>>> code-readable-1.c would be fine. >>>>> >>>>> >>>>> >>>>> I'm having problems with this part -- it seems like every combination >>>>> of >>>>> options with -mabi=64 I've tried with code-readable-1.c complains about >>>>> something-or-another being incompatible. The closest I've come is >>>>> "-mabi=64 >>>>> -march=mips64 -msoft-float", which is accepted by the >>>>> mipsisa32r2-sde-elf >>>> >>>> >>>> Did you test this at all on a mips64-*-* target? After this change >>>> n64 jump tables are broken. >>>> Before CASE_VECTOR_MODE was DImode for n64 . >>>> >>>> See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54371 for why it fails. >>>> gpdword produces a double word for n64. >>>> >>>> For EABI64 it is ok to load 32bits because that the addresses are >>>> 32bits but for n64, it is not ok. The load addresses are normally >>>> above the 32bits boundary. >>> >>> >>> I am testing a patch which changes CASE_VECTOR_MODE to be: >>> #define CASE_VECTOR_MODE ((mips_abi == ABI_64) ? DImode : SImode) >> >> >> I think it should be: >> >> #define CASE_VECTOR_MODE \ >> (TARGET_MIPS16_SHORT_JUMP_TABLES ? SImode : ptr_mode) >> >> #define CASE_VECTOR_SHORTEN_MODE(MIN, MAX, BODY) \ >> (!TARGET_MIPS16_SHORT_JUMP_TABLES ? ptr_mode \ >> : (MIN)>= -32768&& (MAX)< 32768 : HImode \ >> >> : SImode) >> >> The point being that the TARGET_MIPS16_SHORT_JUMP_TABLES entries >> are relative, so SImode would be correct there even for n64. >> >> I'd missed that CASE_VECTOR_MODE applied to tablejump as well >> as casesi, sorry. > > > Yeah, sorry. :-( The original version of the patch I posted (where > CASE_VECTOR_MODE was #defined to ptr_mode) had indeed been tested on mips64, > but not the revised version that was approved for check-in. Here is the patch which I applied after a bootstrap/test on mips64-linux-gnu. Thanks, Andrew Pinski ChangeLog: * config/mips/mips.h (CASE_VECTOR_MODE): For not TARGET_MIPS16_SHORT_JUMP_TABLES use ptr_mode. (CASE_VECTOR_SHORTEN_MODE): Likewise. Index: config/mips/mips.h =================================================================== --- config/mips/mips.h (revision 190638) +++ config/mips/mips.h (working copy) @@ -2336,12 +2336,13 @@ typedef struct mips_args { #define JUMP_TABLES_IN_TEXT_SECTION TARGET_MIPS16_SHORT_JUMP_TABLES -#define CASE_VECTOR_MODE SImode +#define CASE_VECTOR_MODE (TARGET_MIPS16_SHORT_JUMP_TABLES ? SImode : ptr_mode) /* Only use short offsets if their range will not overflow. */ #define CASE_VECTOR_SHORTEN_MODE(MIN, MAX, BODY) \ - (TARGET_MIPS16_SHORT_JUMP_TABLES && ((MIN) >= -32768 && (MAX) < 32768) \ - ? HImode : SImode) + (!TARGET_MIPS16_SHORT_JUMP_TABLES ? ptr_mode \ + : ((MIN) >= -32768 && (MAX) < 32768) ? HImode \ + : SImode) #define CASE_VECTOR_PC_RELATIVE TARGET_MIPS16_SHORT_JUMP_TABLES