From patchwork Mon Mar 21 13:06:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 600119 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 3qTGLw5kZQz9s5g for ; Tue, 22 Mar 2016 00:07:04 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=Tn837gIX; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=IWUgEiAi69pDLdUel lCKY55PLAfYn2xzrl4ASCihI7OIOOBHNKQiBEoJkilE75Z/JoafeuRCVfEfW3XLS Y5jJM71rxMgnSo4NRWg2dpeyi/pOCaXJ1hs+GkrvVOtK9UBLmi0oJYiXz5ix4ACc JwMBgQI/3LznyNWNFbdu688VvU= 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:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=default; bh=+sFtGZr2hKk/dtVp0VSYL23 GWoM=; b=Tn837gIXJj0mb9DFQ1gULTJCbL0OckDd+JpPMdwenBwx6K3XNLFNV7D UPh0LfMbfiAPH9U4jxUWlJHBFawhMbDzxEW1AXRXHTojsQUN4qQD3YUA2hlgOsXE hNCcSwYKd1YyHRa5yCx12bTVADshu9hE9zAyZOcevJRorxfrCUaM= Received: (qmail 8071 invoked by alias); 21 Mar 2016 13:06:56 -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 8052 invoked by uid 89); 21 Mar 2016 13:06:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-pf0-f193.google.com Received: from mail-pf0-f193.google.com (HELO mail-pf0-f193.google.com) (209.85.192.193) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 21 Mar 2016 13:06:54 +0000 Received: by mail-pf0-f193.google.com with SMTP id q129so30459201pfb.3 for ; Mon, 21 Mar 2016 06:06:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=HIRnFjra6tNg8iKoiTOSOrN82M1qmAjv+1+qYLr8TEY=; b=DdcNbLq00m1ABNbDJfuNDuCc2KcPYMAiGLSdbZZYLPVL9IHTrg8tWX9YzOJux+vlmI UO7kYojQy7VDySkimHn89jGIZ3az2lCDRmPaQ7PwXRncmJziWKp8LXiRHawOANr3snh4 XkGK/wkghFta49OIlapIRlHHV9KjFgmESVW+dDrLZ1VE/fchsWRtS/OigDHbEChYBWRw Z+DOtoqQjYPUrSR6LxeVc9y48SQiEtl+DLJ1goWv+v4rKv4A2XyAzkh1abbY02L6ZcUG /aLluI/cPjse9alsI8M5WQfFW7B8grkIhMfm7d9Xm8CQdlSDey4LLoEiGM3Imti10pbG EP8A== X-Gm-Message-State: AD7BkJJSOZk3p+cF3ZWsJ6wOLEW7dLJZoMmiGZgF0uwgCtu6Gv1a43tQ4OusOLN9u/N1fg== X-Received: by 10.98.18.195 with SMTP id 64mr45151396pfs.131.1458565612417; Mon, 21 Mar 2016 06:06:52 -0700 (PDT) Received: from bubble.grove.modra.org (CPE-58-160-146-233.sa.bigpond.net.au. [58.160.146.233]) by smtp.gmail.com with ESMTPSA id k88sm40773802pfj.0.2016.03.21.06.06.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Mar 2016 06:06:51 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 8A283EA0153; Mon, 21 Mar 2016 23:36:48 +1030 (ACDT) Date: Mon, 21 Mar 2016 23:36:48 +1030 From: Alan Modra To: gcc-patches@gcc.gnu.org Cc: David Edelsohn Subject: [PATCH 2/4] [RS6000] PR69645, -ffixed-reg ignored Message-ID: <20160321130648.GN22605@bubble.grove.modra.org> References: <20160321130459.GL22605@bubble.grove.modra.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160321130459.GL22605@bubble.grove.modra.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes Treat -ffixed-reg as we do for global asm regs. The only slightly complicated part of this patch is that the rs6000 backend itself sets fixed_regs[RS6000_PIC_OFFSET_TABLE_REGNUM] in some cases, which means we can't simply test fixed_regs[] to determine whether a reg appeared as -ffixed-reg. PR target/69645 * config/rs6000/rs6000.c (fixed_reg_p): New function. (fixed_regs_p): Rename from global_regs_p. Call fixed_reg_p. Update all uses. diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 0e570e4..99473bd 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -22996,17 +22996,34 @@ is_altivec_return_reg (rtx reg, void *xyes) } -/* Look for user-defined global regs in the range FIRST to LAST-1. - We should not restore these, and so cannot use lmw or out-of-line - restore functions if there are any. We also can't save them - (well, emit frame notes for them), because frame unwinding during - exception handling will restore saved registers. */ +/* Return whether REG is a global user reg or has been specifed by + -ffixed-REG. */ static bool -global_regs_p (unsigned first, unsigned last) +fixed_reg_p (int reg) +{ + /* Ignore fixed_regs[RS6000_PIC_OFFSET_TABLE_REGNUM] when the + backend sets it, overriding anything the user might have given. */ + if (reg == RS6000_PIC_OFFSET_TABLE_REGNUM + && ((DEFAULT_ABI == ABI_V4 && flag_pic) + || (DEFAULT_ABI == ABI_DARWIN && flag_pic) + || (TARGET_TOC && TARGET_MINIMAL_TOC))) + return false; + + return fixed_regs[reg]; +} + +/* Look for user-defined global regs or -ffixed- in the range + FIRST to LAST-1. We should not restore these, and so cannot use + lmw or out-of-line restore functions if there are any. We also + can't save them (well, emit frame notes for them), because frame + unwinding during exception handling will restore saved registers. */ + +static bool +fixed_regs_p (unsigned first, unsigned last) { while (first < last) - if (global_regs[first++]) + if (fixed_reg_p (first++)) return true; return false; } @@ -23037,7 +23054,7 @@ rs6000_savres_strategy (rs6000_stack_t *info, && !TARGET_POWERPC64 && !(TARGET_SPE_ABI && info->spe_64bit_regs_used) && info->first_gp_reg_save < 31 - && !global_regs_p (info->first_gp_reg_save, 32)) + && !fixed_regs_p (info->first_gp_reg_save, 32)) strategy |= SAVRES_MULTIPLE; if (crtl->calls_eh_return @@ -23050,16 +23067,16 @@ rs6000_savres_strategy (rs6000_stack_t *info, /* The out-of-line FP routines use double-precision stores; we can't use those routines if we don't have such stores. */ || (TARGET_HARD_FLOAT && !TARGET_DOUBLE_FLOAT) - || global_regs_p (info->first_fp_reg_save, 64)) + || fixed_regs_p (info->first_fp_reg_save, 64)) strategy |= SAVE_INLINE_FPRS | REST_INLINE_FPRS; if (info->first_gp_reg_save == 32 || (!(strategy & SAVRES_MULTIPLE) - && global_regs_p (info->first_gp_reg_save, 32))) + && fixed_regs_p (info->first_gp_reg_save, 32))) strategy |= SAVE_INLINE_GPRS | REST_INLINE_GPRS; if (info->first_altivec_reg_save == LAST_ALTIVEC_REGNO + 1 - || global_regs_p (info->first_altivec_reg_save, LAST_ALTIVEC_REGNO + 1)) + || fixed_regs_p (info->first_altivec_reg_save, LAST_ALTIVEC_REGNO + 1)) strategy |= SAVE_INLINE_VRS | REST_INLINE_VRS; /* Define cutoff for using out-of-line functions to save registers. */