From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2723 invoked by alias); 18 May 2007 07:02:22 -0000 Received: (qmail 2712 invoked by uid 22791); 18 May 2007 07:02:18 -0000 X-Spam-Check-By: sourceware.org Received: from gateway.codesourcery.com (HELO gateway.codesourcery.com) (65.74.133.9) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 18 May 2007 07:02:00 +0000 Received: (qmail 29180 invoked by uid 1010); 18 May 2007 07:01:58 -0000 From: Richard Sandiford To: DJ Delorie Mail-Followup-To: DJ Delorie ,gcc-patches@gcc.gnu.org, richard@codesourcery.com Cc: gcc-patches@gcc.gnu.org Subject: Re: mips tls with -mlong64/-mgp32 References: <200705102046.l4AKkiB4017813@greed.delorie.com> <20070510212451.GA2251@caradoc.them.org> <200705102127.l4ALRckj018854@greed.delorie.com> <871whna72x.fsf@firetop.home> <200705111222.l4BCMmn1029370@greed.delorie.com> <87wszf8qr3.fsf@firetop.home> <200705111305.l4BD556S030628@greed.delorie.com> <87k5vf8pm6.fsf@firetop.home> <20070511133321.GA1076@caradoc.them.org> <878xbv8oid.fsf@firetop.home> <200705171910.l4HJAvGW023479@greed.delorie.com> <87tzubs112.fsf@firetop.home> <200705171949.l4HJnhA9024026@greed.delorie.com> <87ps4zrzgt.fsf@firetop.home> <200705172009.l4HK9oFF024588@greed.delorie.com> <87hcqbryyt.fsf@firetop.home> <200705172055.l4HKt5wV030413@greed.delorie.com> <87abw3rv5o.fsf@firetop.home> <200705172306.l4HN6g6S031357@greed.delorie.com> Date: Fri, 18 May 2007 07:02:00 -0000 In-Reply-To: <200705172306.l4HN6g6S031357@greed.delorie.com> (DJ Delorie's message of "Thu, 17 May 2007 19:06:42 -0400") Message-ID: <874pmasjh6.fsf@firetop.home> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2007-05/txt/msg01188.txt.bz2 DJ Delorie writes: > +/* Returns true if OFFSET is within the range [0, ALIGN), where ALIGN > + is the alignment (in bytes) of SYMBOL_REF X. */ (thanks for adding the "(in bytes)" btw.) > +static bool > +mips_offset_within_alignment_p (rtx x, HOST_WIDE_INT offset) > +{ > + /* If for some reason we can't get the alignment for the > + symbol, initializing this to zero means we won't accept any > + offset. */ > + HOST_WIDE_INT align = 0; I suppose with the way I've speced the function, this ought to be: /* If for some reason we can't get the alignment for the symbol, initializing this to one means we'll only accept a zero offset. */ HOST_WIDE_INT align = 1; > + tree t; > + > + /* Get the alignment of the symbol we're referring to. */ > + t = SYMBOL_REF_DECL (x); > + if (t) > + align = DECL_ALIGN_UNIT (t); > + > + if (offset < align) > + return true; > + return false; This should check for negative offsets too. Just change the last three statements to: return offset >= 0 && offset < align; > @@ -1413,20 +1439,26 @@ mips_symbolic_constant_p (rtx x, enum mi > address, and we will apply a 16-bit offset after loading it. > If the symbol is local, the linker should provide enough local > GOT entries for a 16-bit offset, but larger offsets may lead > to GOT overflow. */ > return SMALL_INT (offset); > > + case SYMBOL_TPREL: > + case SYMBOL_DTPREL: > + /* There is no carry between the HI and LO REL relocations, so the > + offset is only valid if we know it won't lead to such a carry. */ > + if (mips_offset_within_alignment_p (x, INTVAL (offset))) > + return true; > + /* Fall through. */ > + > case SYMBOL_GOT_DISP: > case SYMBOL_GOTOFF_DISP: > case SYMBOL_GOTOFF_CALL: > case SYMBOL_GOTOFF_LOADGP: > case SYMBOL_TLSGD: > case SYMBOL_TLSLDM: > - case SYMBOL_DTPREL: > - case SYMBOL_TPREL: > case SYMBOL_GOTTPREL: > case SYMBOL_TLS: > case SYMBOL_HALF: > return false; > } > gcc_unreachable (); This isn't right, you fall through a gcc_unreachable (). Just change it to: /* There is no carry between the HI and LO REL relocations, so the offset is only valid if we know it won't lead to such a carry. */ return mips_offset_within_alignment_p (x, INTVAL (offset)); OK with those changes, if it survives testing. Thanks, Richard