From patchwork Thu Jun 19 12:39:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 361856 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 AA565140086 for ; Thu, 19 Jun 2014 22:40:18 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=uHfdTvlb6t8+Abnmr xU5wGaZKUx7XjDzGrWYmZnS2KTcZlpD0+BuhUagnclvkkAzQhln9tIjIvrgStrB0 e96+g8e004YLCO7xnPBg5fVG1HQIQ3k8ysd2nwx7/K1Ds/sQ3Q/9+pv+WdIGQ/Zn e2R8Ipod7nU9h8O/8ENxrxSFzw= 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 :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; s=default; bh=j7/HrjXatUGbZzMIOcT8vKe Ep+I=; b=KUBP822SWD31598AA2bLevgwM+AwI45H3VqEI/rF9USI8u1LOpOnWKn TAKkTLr8VnaJ8nFzebEJjoQvqjrrXWzIFApDIdzLNRYCPlJ1vd5qWc99UuUfhnkn Xw3SiavyNliDh0qonvIT+CP3UhAV2YabXh1BVQUvYlxOIq7sIV+Q= Received: (qmail 30830 invoked by alias); 19 Jun 2014 12:40:11 -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 30813 invoked by uid 89); 19 Jun 2014 12:40:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 19 Jun 2014 12:40:07 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1WxbdK-0001MS-Fo from Tom_deVries@mentor.com ; Thu, 19 Jun 2014 05:40:02 -0700 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 19 Jun 2014 05:40:02 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.2.247.3; Thu, 19 Jun 2014 13:40:00 +0100 Message-ID: <53A2DA1D.80909@mentor.com> Date: Thu, 19 Jun 2014 14:39:57 +0200 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: Richard Henderson CC: Eric Botcazou , , Jan Hubicka , Subject: Re: -fuse-caller-save - Collect register usage information References: <534ED7BC.50300@mentor.com> <878uqwgjoe.fsf@talisman.default> <535BABD1.8050208@mentor.com> <1426417.RtLpSRnsYv@polaris> <537A1583.7020702@mentor.com> <53A27162.7070208@redhat.com> In-Reply-To: <53A27162.7070208@redhat.com> On 19-06-14 07:13, Richard Henderson wrote: > On 05/19/2014 07:30 AM, Tom de Vries wrote: >> >+ for (insn = get_insns (); insn != NULL_RTX; insn = next_insn (insn)) >> >+ { >> >+ HARD_REG_SET insn_used_regs; >> >+ >> >+ if (!NONDEBUG_INSN_P (insn)) >> >+ continue; >> >+ >> >+ find_all_hard_reg_sets (insn, &insn_used_regs, false); >> >+ >> >+ if (CALL_P (insn) >> >+ && !get_call_reg_set_usage (insn, &insn_used_regs, call_used_reg_set)) >> >+ { >> >+ CLEAR_HARD_REG_SET (node->function_used_regs); >> >+ return; >> >+ } >> >+ >> >+ IOR_HARD_REG_SET (node->function_used_regs, insn_used_regs); >> >+ } > As an aside, wouldn't it work out better if we collect into a local variable > instead of writing to memory here in node->function_used_regs each time? Richard, Agreed. This patch implements that. I'll bootstrap and reg-test on x86_64 and commit as obvious. Thanks, - Tom 2014-06-19 Tom de Vries * final.c (collect_fn_hard_reg_usage): Add and use variable function_used_regs. diff --git a/gcc/final.c b/gcc/final.c index 4f08073..e39930d 100644 --- a/gcc/final.c +++ b/gcc/final.c @@ -4760,13 +4760,13 @@ collect_fn_hard_reg_usage (void) int i; #endif struct cgraph_rtl_info *node; + HARD_REG_SET function_used_regs; /* ??? To be removed when all the ports have been fixed. */ if (!targetm.call_fusage_contains_non_callee_clobbers) return; - node = cgraph_rtl_info (current_function_decl); - gcc_assert (node != NULL); + CLEAR_HARD_REG_SET (function_used_regs); for (insn = get_insns (); insn != NULL_RTX; insn = next_insn (insn)) { @@ -4779,25 +4779,26 @@ collect_fn_hard_reg_usage (void) if (CALL_P (insn) && !get_call_reg_set_usage (insn, &insn_used_regs, call_used_reg_set)) - { - CLEAR_HARD_REG_SET (node->function_used_regs); - return; - } + return; - IOR_HARD_REG_SET (node->function_used_regs, insn_used_regs); + IOR_HARD_REG_SET (function_used_regs, insn_used_regs); } /* Be conservative - mark fixed and global registers as used. */ - IOR_HARD_REG_SET (node->function_used_regs, fixed_reg_set); + IOR_HARD_REG_SET (function_used_regs, fixed_reg_set); #ifdef STACK_REGS /* Handle STACK_REGS conservatively, since the df-framework does not provide accurate information for them. */ for (i = FIRST_STACK_REG; i <= LAST_STACK_REG; i++) - SET_HARD_REG_BIT (node->function_used_regs, i); + SET_HARD_REG_BIT (function_used_regs, i); #endif + node = cgraph_rtl_info (current_function_decl); + gcc_assert (node != NULL); + + COPY_HARD_REG_SET (node->function_used_regs, function_used_regs); node->function_used_regs_valid = 1; } -- 1.9.1