From patchwork Wed Nov 12 21:51:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 410125 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 66DDB1400E7 for ; Thu, 13 Nov 2014 08:51:12 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; q=dns; s=default; b=rYBnIU77kplI6qLFG9 ISYVjnmHR8GVauyWWFzvg9VnnwhNrZ0qUpjPKRL9SBpF3Of2NClxKLRuVgpd31Jk Zwn2e9/RL2UkBVwyQgEqgyidbVQ6g6wA5ehj60nXxs09WzuZtrZAvML4gI2o2pk2 u3aE849fSzE1/N+ghBDgtWznY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; s=default; bh=sRzaqMYCZnu5Th9Y2XQQ0ORK 0BA=; b=r4pWLWz9k7KKj+w9ch/4wZpZbVsxkN8RiFen2MIV9C2D+Ky1RaLsn4bd LM2pIybxaH27Gr2WBrluwJEqYWzLNeLP7/vOl42AjRGkZt7zMiAkVh+B2tI1jBiZ lbFERvBNSrCVVZNFFXmKdCrs98l3IGwAybXDCSclumyJE8cMmLg= Received: (qmail 5621 invoked by alias); 12 Nov 2014 21:51:05 -0000 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 Received: (qmail 5604 invoked by uid 89); 12 Nov 2014 21:51:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ob0-f180.google.com Received: from mail-ob0-f180.google.com (HELO mail-ob0-f180.google.com) (209.85.214.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 12 Nov 2014 21:51:03 +0000 Received: by mail-ob0-f180.google.com with SMTP id wp4so9725190obc.25 for ; Wed, 12 Nov 2014 13:51:01 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.60.41.170 with SMTP id g10mr1192448oel.53.1415829061699; Wed, 12 Nov 2014 13:51:01 -0800 (PST) Received: by 10.76.84.102 with HTTP; Wed, 12 Nov 2014 13:51:01 -0800 (PST) In-Reply-To: <20141112213931.GR5026@tucnak.redhat.com> References: <20141112204317.GA13104@intel.com> <20141112210249.GQ5026@tucnak.redhat.com> <20141112213931.GR5026@tucnak.redhat.com> Date: Wed, 12 Nov 2014 13:51:01 -0800 Message-ID: Subject: Re: PATCH: PR target/63815: [5 Regression] g++.dg/other/pr53811.C fails with -mcmodel=large -fpic From: "H.J. Lu" To: Jakub Jelinek Cc: GCC Patches , Uros Bizjak X-IsSubscribed: yes On Wed, Nov 12, 2014 at 1:39 PM, Jakub Jelinek wrote: > On Wed, Nov 12, 2014 at 01:11:40PM -0800, H.J. Lu wrote: >> On Wed, Nov 12, 2014 at 1:02 PM, Jakub Jelinek wrote: >> > On Wed, Nov 12, 2014 at 12:43:17PM -0800, H.J. Lu wrote: >> >> @@ -42686,8 +42692,12 @@ x86_output_mi_thunk (FILE *file, tree, HOST_WIDE_INT delta, >> >> else >> >> { >> >> if (ix86_cmodel == CM_LARGE_PIC && SYMBOLIC_CONST (fnaddr)) >> >> - fnaddr = legitimize_pic_address (fnaddr, >> >> - gen_rtx_REG (Pmode, tmp_regno)); >> >> + { >> >> + SET_REGNO (pic_offset_table_rtx, R11_REG); >> > >> > If pic_offset_table_rtx has never been initialized, how you can use >> >> It is a pseudo PIC register which is uninitialized: >> >> (gdb) call debug_rtx (this_target_rtl->x_pic_offset_table_rtx) >> (reg:DI 89) >> (gdb) >> >> > SET_REGNO on it? Shouldn't that be pic_offset_table_rtx = gen_raw_REG (Pmode, R11_REG); >> >> I added the following comments and am checking it into trunk: >> >> // CM_LARGE_PIC always uses pseudo PIC register which is >> // uninitialized. Since FUNCTION is local and calling it >> // doesn't go through PLT, we use scratch register %r11 as >> // PIC register and initialize it here. > > From what I can see, it probably in this case should be always non-NULL, > as it is initialized in init_emit_regs: > 5847 if ((unsigned) PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM) > 5848 pic_offset_table_rtx = gen_raw_REG (Pmode, PIC_OFFSET_TABLE_REGNUM); > 5849 else > 5850 pic_offset_table_rtx = NULL_RTX; > and as pic_offset_table_rtx is NULL there, PIC_OFFSET_TABLE_REGNUM is > BX_REG. > Later on, assign_params will change that to: > 3684 if (targetm.use_pseudo_pic_reg ()) > 3685 pic_offset_table_rtx = gen_reg_rtx (Pmode); > and do_reload, after reload temporarily changing the REGNO, will overwrite > it again to the chosen pseudo: > 5470 if (pic_offset_table_regno != INVALID_REGNUM) > 5471 pic_offset_table_rtx = gen_rtx_REG (Pmode, pic_offset_table_regno); > > So, all in all, SET_REGNO sounds inappropriate to me, everywhere else > gen_raw_REG or gen_rtx_REG is used instead, so IMNSHO you should do the > same. > > Jakub It makes sense. I checked in the following patch. Thanks. Index: ChangeLog =================================================================== --- ChangeLog (revision 217445) +++ ChangeLog (working copy) @@ -1,5 +1,10 @@ 2014-11-12 H.J. Lu + * config/i386/i386.c (x86_output_mi_thunk): Set gen_rtx_REG to + set pic_offset_table_rtx. + +2014-11-12 H.J. Lu + PR target/63815 * config/i386/i386.c (ix86_init_large_pic_reg): New. Extracted from ... Index: config/i386/i386.c =================================================================== --- config/i386/i386.c (revision 217445) +++ config/i386/i386.c (working copy) @@ -42697,7 +42697,7 @@ x86_output_mi_thunk (FILE *file, tree, H // uninitialized. Since FUNCTION is local and calling it // doesn't go through PLT, we use scratch register %r11 as // PIC register and initialize it here. - SET_REGNO (pic_offset_table_rtx, R11_REG); + pic_offset_table_rtx = gen_rtx_REG (Pmode, R11_REG); ix86_init_large_pic_reg (tmp_regno); fnaddr = legitimize_pic_address (fnaddr, gen_rtx_REG (Pmode, tmp_regno));