From patchwork Wed Jan 2 13:12:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 209041 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 310EC2C007B for ; Thu, 3 Jan 2013 00:12:23 +1100 (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=1357737144; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: From:To:Mail-Followup-To:Cc:Subject:References:Date:In-Reply-To: Message-ID:User-Agent:MIME-Version:Content-Type:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=TPoiinYW54Swclwdo9vOIV5bNwk=; b=nd03G33xcFEszSmNvdMr8KxiL81IeTVdOJ/aa3TV4+0lNbaHLr11arU4egYKOc lmh+z+IQ6IjvPQe4ABHDZNyx75AAWRQE0mIpnKm05afjpkfLMOf7VsKs20lpdSu5 KglhrrOeAd4az3VVnCx4yCLwy9ser0uKoj6E64rPqijw8= 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:X-Received:Received:From:To:Mail-Followup-To:Cc:Subject:References:Date:In-Reply-To:Message-ID:User-Agent:MIME-Version:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=fakDOrpSx1j1wscaox4U7fBqZ21PzmqSXJCkk7PTGXK9pKxGXm/qgRoU68vgd9 Bb/CHqyqc5rQ6SXtesjtCgow53vDY/TX5bEoTAL9uVDcrYJh3xHvB69qUY34P+ig B88qD7cS9P8L0fMntMaqWyi6KrAdJmEuQy7F1nAufIgZY=; Received: (qmail 4707 invoked by alias); 2 Jan 2013 13:12:18 -0000 Received: (qmail 4404 invoked by uid 22791); 2 Jan 2013 13:12:18 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=AWL, BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, KAM_STOCKGEN, KHOP_RCVD_TRUST, KHOP_SPAMHAUS_DROP, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-wg0-f43.google.com (HELO mail-wg0-f43.google.com) (74.125.82.43) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 02 Jan 2013 13:12:13 +0000 Received: by mail-wg0-f43.google.com with SMTP id e12so6335531wge.34 for ; Wed, 02 Jan 2013 05:12:11 -0800 (PST) X-Received: by 10.180.99.72 with SMTP id eo8mr63961519wib.34.1357132331594; Wed, 02 Jan 2013 05:12:11 -0800 (PST) Received: from localhost ([2.26.203.77]) by mx.google.com with ESMTPS id p3sm84934664wic.8.2013.01.02.05.12.09 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 02 Jan 2013 05:12:10 -0800 (PST) From: Richard Sandiford To: John David Anglin Mail-Followup-To: John David Anglin , gcc-patches@gcc.gnu.org, rdsandiford@googlemail.com Cc: gcc-patches@gcc.gnu.org Subject: Re: [committed] Fix ICE in gen_reg_rtx, at emit-rtl.c:864/865 compiling GNU MPFR References: <20121226193718.GA25173@hiauly1.hia.nrc.ca> Date: Wed, 02 Jan 2013 13:12:00 +0000 In-Reply-To: <20121226193718.GA25173@hiauly1.hia.nrc.ca> (John David Anglin's message of "Wed, 26 Dec 2012 14:37:18 -0500") Message-ID: <87sj6j7mqn.fsf@talisman.default> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) MIME-Version: 1.0 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 John David Anglin writes: > The attached change fixes PR target/5379. ICE occurs when reload tries > to emit a move instruction containing a TLS symbol reference as the source > operand. This requires several scratch registers. As a result, it isn't > possible for a reload pattern to handle this case. So, the best solution > was to reject TLS symbol reference source operands after reload starts. > > Tested on hppa-unknown-linux-gnu and hppa2.0w-hp-hpux11.11 with not observed > regressions. > > Committed to all active branches. > > Dave > > 2012-12-25 John David Anglin > > PR target/53789 > * config/pa/pa.md (movsi): Reject expansion of TLS symbol references > after reload starts. > > Index: config/pa/pa.md > =================================================================== > --- config/pa/pa.md (revision 194709) > +++ config/pa/pa.md (working copy) > @@ -2051,6 +2110,12 @@ > "" > " > { > + /* A TLS symbol reference is not a valid move source operand. > + pa_emit_move_sequence can only handle them prior to reload. > + There is also no way to reload a TLS symbol reference, so > + we must reject them after reload starts. */ > + if (PA_SYMBOL_REF_TLS_P (operands[1]) && !can_create_pseudo_p ()) > + FAIL; > if (pa_emit_move_sequence (operands, SImode, 0)) > DONE; > }") Sorry to butt in, but I'm not sure about this. Move patterns aren't supposed to fail. The nasty thing is that all FAIL actually does is make the generator return null, and emitting a null insn is a no-op. That means code like: /* from emit_move_insn_1 */ code = optab_handler (mov_optab, mode); if (code != CODE_FOR_nothing) return emit_insn (GEN_FCN (code) (x, y)); ... emit_move_insn{,_1} (x, y); won't generate an ICE on FAIL, but it won't generate any insns either. If someone's feeling brave, they might want to add an assert for nonnull. In any case, reload needs to know up-front that the constant can't be rematerialised, via LEGITIMATE_CONSTANT_P. emit_move_insn_1 would be too late. It looks like PA already handles this for some TLS models: /* TLS_MODEL_GLOBAL_DYNAMIC and TLS_MODEL_LOCAL_DYNAMIC are not legitimate constants. */ if (PA_SYMBOL_REF_TLS_P (x)) { enum tls_model model = SYMBOL_REF_TLS_MODEL (x); if (model == TLS_MODEL_GLOBAL_DYNAMIC || model == TLS_MODEL_LOCAL_DYNAMIC) return false; } so maybe that should just be: if (PA_SYMBOL_REF_TLS_P (x)) return false; ? It probably ought to handle symbol + constant too though. FWIW, I wrote the test below just to make sure that this worked for mips64-linux-gnu. OK to install? ...although I just tried it on x86_64-linux-gnu and it ICEs there. Richard gcc/testsuite/ * gcc.dg/torture/tls/tls-reload-1.c: New test. Index: gcc/testsuite/gcc.dg/torture/tls/tls-reload-1.c =================================================================== --- /dev/null 2012-12-29 10:15:03.199289441 +0000 +++ gcc/testsuite/gcc.dg/torture/tls/tls-reload-1.c 2013-01-02 12:56:22.278837979 +0000 @@ -0,0 +1,48 @@ +/* { dg-do run } */ +/* { dg-require-effective-target tls_runtime } */ + +#define ARRAY(X) X##_array +#define DECLARE(X) \ + __thread int X; \ + __thread int ARRAY(X)[4]; \ + int *volatile *__attribute__((noinline)) \ + check##X (int *volatile *y) \ + { \ + if (!y || *y++ != &X || *y++ != &ARRAY(X)[3]) \ + return 0; \ + return y; \ + } +#define COPY(X) *y++ = &X; *y++ = &ARRAY(X)[3]; +#define CHECK(X) y = check##X (y); +#define A(M, X) M(X##0) M(X##1) M(X##2) M(X##3) M(X##4) M(X##5) M(X##6) M(X##7) +#define B(M, X) A(M, X##0) A(M, X##1) A(M, X##2) +#define C(M, X) B(M, X) B(M, X) B(M, X) + +#define NM 2 +#define NA (NM * 8) +#define NB (NA * 3) +#define NC (NB * 3) + +extern void abort (void); + +B(DECLARE, tls) + +void __attribute__ ((noinline)) +setup (int *volatile *y) +{ + C(COPY, tls) +} + +int +main (void) +{ + int *volatile array[NC]; + int *volatile *y = array; + int i; + + setup (array); + B(CHECK, tls); + if (!y) + abort (); + return 0; +}