From patchwork Wed Jan 17 16:00:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 862341 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-471488-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="DoKkT+DH"; dkim-atps=neutral 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 3zMBdf5GvZz9s75 for ; Thu, 18 Jan 2018 03:00:54 +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:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=Av5DItHkzshkw5Kx4WB3xNFKX5pUr 5562sjJNJGVryfxVF4+ieJLLu4S4emVq0mmm2z0VzENMTejar90Lv4dq/udmXYxd 2EIth5p8Pv/HpdpnoJ6ufHo9b6Ggi7blxYXMmeVFCcf9SRvWvW7/dzdTvnYE7kl7 s16JI5GoKKDh2k= 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:reply-to:mime-version :content-type; s=default; bh=+cIp15mroqk6+yvfqrawyy52vA4=; b=DoK kT+DHQuMcaWVSltF/v0RYoxBYBcD4J/CWayt3uQ3FBG6yp8FdewVpTxkmIk3il6r I2s7BhGnMoxAIa8W8hURYQACnS8fxBowrBzk+5rqx7e1IpXZ8Fh8IjGzdn1BST2G SbltHf4UGR+29cuc/EsGezpfzinLDfIhqE/R60EU= Received: (qmail 54276 invoked by alias); 17 Jan 2018 16:00:46 -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 54200 invoked by uid 89); 17 Jan 2018 16:00:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, NO_DNS_FOR_FROM, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mga04.intel.com Received: from mga04.intel.com (HELO mga04.intel.com) (192.55.52.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 17 Jan 2018 16:00:38 +0000 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Jan 2018 08:00:15 -0800 X-ExtLoop1: 1 Received: from gnu-6.sc.intel.com ([172.25.70.218]) by orsmga005.jf.intel.com with ESMTP; 17 Jan 2018 08:00:15 -0800 Received: by gnu-6.sc.intel.com (Postfix, from userid 1000) id 56513201470; Wed, 17 Jan 2018 08:00:15 -0800 (PST) Date: Wed, 17 Jan 2018 08:00:15 -0800 From: "H.J. Lu" To: gcc-patches@gcc.gnu.org Cc: Uros Bizjak Subject: [PATCH] i386: Use const reference of struct ix86_frame to avoid copy Message-ID: <20180117160015.GA11885@gmail.com> Reply-To: "H.J. Lu" MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.1 (2017-09-22) We can use const reference of struct ix86_frame to avoid making a local copy of ix86_frame. ix86_expand_epilogue makes a local copy of struct ix86_frame and uses the reg_save_offset field as a local variable. This patch uses a separate local variable for reg_save_offset. Tested on x86-64 with ada. OK for trunk? H.J. --- PR target/83905 * config/i386/i386.c (ix86_expand_prologue): Use cost reference of struct ix86_frame. (ix86_expand_epilogue): Likewise. Add a local variable for the reg_save_offset field in struct ix86_frame. --- gcc/config/i386/i386.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index a301e18ed70..340eca42449 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -13385,7 +13385,6 @@ ix86_expand_prologue (void) { struct machine_function *m = cfun->machine; rtx insn, t; - struct ix86_frame frame; HOST_WIDE_INT allocate; bool int_registers_saved; bool sse_registers_saved; @@ -13413,7 +13412,7 @@ ix86_expand_prologue (void) m->fs.sp_valid = true; m->fs.sp_realigned = false; - frame = m->frame; + const struct ix86_frame &frame = cfun->machine->frame; if (!TARGET_64BIT && ix86_function_ms_hook_prologue (current_function_decl)) { @@ -14291,7 +14290,6 @@ ix86_expand_epilogue (int style) { struct machine_function *m = cfun->machine; struct machine_frame_state frame_state_save = m->fs; - struct ix86_frame frame; bool restore_regs_via_mov; bool using_drap; bool restore_stub_is_tail = false; @@ -14304,7 +14302,7 @@ ix86_expand_epilogue (int style) } ix86_finalize_stack_frame_flags (); - frame = m->frame; + const struct ix86_frame &frame = cfun->machine->frame; m->fs.sp_realigned = stack_realign_fp; m->fs.sp_valid = stack_realign_fp @@ -14348,11 +14346,13 @@ ix86_expand_epilogue (int style) + UNITS_PER_WORD); } + HOST_WIDE_INT reg_save_offset = frame.reg_save_offset; + /* Special care must be taken for the normal return case of a function using eh_return: the eax and edx registers are marked as saved, but not restored along this path. Adjust the save location to match. */ if (crtl->calls_eh_return && style != 2) - frame.reg_save_offset -= 2 * UNITS_PER_WORD; + reg_save_offset -= 2 * UNITS_PER_WORD; /* EH_RETURN requires the use of moves to function properly. */ if (crtl->calls_eh_return) @@ -14368,11 +14368,11 @@ ix86_expand_epilogue (int style) else if (TARGET_EPILOGUE_USING_MOVE && cfun->machine->use_fast_prologue_epilogue && (frame.nregs > 1 - || m->fs.sp_offset != frame.reg_save_offset)) + || m->fs.sp_offset != reg_save_offset)) restore_regs_via_mov = true; else if (frame_pointer_needed && !frame.nregs - && m->fs.sp_offset != frame.reg_save_offset) + && m->fs.sp_offset != reg_save_offset) restore_regs_via_mov = true; else if (frame_pointer_needed && TARGET_USE_LEAVE @@ -14440,7 +14440,7 @@ ix86_expand_epilogue (int style) rtx t; if (frame.nregs) - ix86_emit_restore_regs_using_mov (frame.reg_save_offset, style == 2); + ix86_emit_restore_regs_using_mov (reg_save_offset, style == 2); /* eh_return epilogues need %ecx added to the stack pointer. */ if (style == 2) @@ -14535,19 +14535,19 @@ ix86_expand_epilogue (int style) in epilogues. */ if (!m->fs.sp_valid || m->fs.sp_realigned || (TARGET_SEH - && (m->fs.sp_offset - frame.reg_save_offset + && (m->fs.sp_offset - reg_save_offset >= SEH_MAX_FRAME_SIZE))) { pro_epilogue_adjust_stack (stack_pointer_rtx, hard_frame_pointer_rtx, GEN_INT (m->fs.fp_offset - - frame.reg_save_offset), + - reg_save_offset), style, false); } - else if (m->fs.sp_offset != frame.reg_save_offset) + else if (m->fs.sp_offset != reg_save_offset) { pro_epilogue_adjust_stack (stack_pointer_rtx, stack_pointer_rtx, GEN_INT (m->fs.sp_offset - - frame.reg_save_offset), + - reg_save_offset), style, m->fs.cfa_reg == stack_pointer_rtx); }