From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20604 invoked by alias); 31 Jul 2017 13:59:12 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 20585 invoked by uid 89); 31 Jul 2017 13:59:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:4605 X-HELO: mail-ua0-f193.google.com Received: from mail-ua0-f193.google.com (HELO mail-ua0-f193.google.com) (209.85.217.193) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 31 Jul 2017 13:59:09 +0000 Received: by mail-ua0-f193.google.com with SMTP id 80so23366835uas.4 for ; Mon, 31 Jul 2017 06:59:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=RERl3nQkP449QoNgIGjH8qaw0U1mf3GSTKwscaw4nBc=; b=g/YoyVc9qT8wFxGTlBoH1x0Yp2cViwWcZ+Rh6lx52pADe8wZCJ0RioKT0rP3lf1QMp yovwea+3P+e7rnfRzzf8bst23J9D/N7C9tUqjB2fge+e/D2KfiE7ePm9jWbMJDme9mQ/ NSOQIZCYc2adkWQ41a1E+q6rdZ3wTnsywoYoYUx3X4xKWzOJXJn0Yzm2tTu1j9++xMRB V6izn8CbpUNeBqK4G2B5Ssu7mdBgflKcaOm9kW3hohmuFxiFpcT/5mFqY60ikXkmxxJq dNsMoXdUE/KMrpfj0EA1KmsWw1Hgh4F9wQH7EAI7U5sS0nTAzCSialB8rGzWjK6YOupR AQng== X-Gm-Message-State: AIVw112BVMxuQ2wLt4F3+fq8cnRpMF7e3/N++t+kIyUJvTIFHJNHCkMU aVHi4e3VM8O7beqRsrLNjKboA/puSA== X-Received: by 10.159.58.204 with SMTP id q12mr11319780uag.7.1501509548142; Mon, 31 Jul 2017 06:59:08 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.68.218 with HTTP; Mon, 31 Jul 2017 06:59:07 -0700 (PDT) In-Reply-To: <20170731112435.30101-3-daniel.santos@pobox.com> References: <20170731112435.30101-3-daniel.santos@pobox.com> From: Uros Bizjak Date: Mon, 31 Jul 2017 13:59:00 -0000 Message-ID: Subject: Re: [PATCH 3/6] [i386] Remove machine_function::call_ms2sysv_pad_out To: Daniel Santos Cc: gcc-patches , Jan Hubicka , Martin Liska , "H . J . Lu" Content-Type: text/plain; charset="UTF-8" X-SW-Source: 2017-07/txt/msg02027.txt.bz2 On Mon, Jul 31, 2017 at 1:24 PM, Daniel Santos wrote: > The -mcall-ms2sysv-xlogues project added the boolean fields > call_ms2sysv_pad_in and call_ms2sysv_pad_out to struct machine_function > to track rather or not an additional 8 bytes of padding was needed for > stack alignment prior to and after the stub save area. This design was > based upon the faulty assumption the function body would not require a > stack alignment greater than 16 bytes. This continues to work well for > managing padding prior to the stub save area, but will not work for the > outgoing alignment. > > Rather than changing machine_function::call_ms2sysv_pad_out to a larger > type, this patch removes it, thus transferring responsibility for stack > alignment following the stub save area from class xlogue_layout to the > body of ix86_compute_frame_layout. Since the 64-bit va_arg register > save area is always a multiple of 16-bytes in size (176 for System V ABI > and 96 for Microsoft ABI), the ROUND_UP calculation for the stack offset > at the start of the function body (frame.frame_pointer_offset) will > assure there is enough room for any padding needed to keep the save area > for SSE va_args 16-byte aligned, so no modification is needed for that > calculation. > > Signed-off-by: Daniel Santos LGTM. OK for mainline. Thanks, Uros. > --- > gcc/config/i386/i386.c | 18 ++++-------------- > gcc/config/i386/i386.h | 8 ++------ > 2 files changed, 6 insertions(+), 20 deletions(-) > > diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c > index 47c5608c3cd..e2e9546a27c 100644 > --- a/gcc/config/i386/i386.c > +++ b/gcc/config/i386/i386.c > @@ -2491,9 +2491,7 @@ public: > unsigned last_reg = m->call_ms2sysv_extra_regs + MIN_REGS - 1; > > gcc_assert (m->call_ms2sysv_extra_regs <= MAX_EXTRA_REGS); > - return m_regs[last_reg].offset > - + (m->call_ms2sysv_pad_out ? 8 : 0) > - + STUB_INDEX_OFFSET; > + return m_regs[last_reg].offset + STUB_INDEX_OFFSET; > } > > /* Returns the offset for the base pointer used by the stub. */ > @@ -12849,13 +12847,12 @@ ix86_compute_frame_layout (void) > { > unsigned count = xlogue_layout::count_stub_managed_regs (); > m->call_ms2sysv_extra_regs = count - xlogue_layout::MIN_REGS; > + m->call_ms2sysv_pad_in = 0; > } > } > > frame->nregs = ix86_nsaved_regs (); > frame->nsseregs = ix86_nsaved_sseregs (); > - m->call_ms2sysv_pad_in = 0; > - m->call_ms2sysv_pad_out = 0; > > /* 64-bit MS ABI seem to require stack alignment to be always 16, > except for function prologues, leaf functions and when the defult > @@ -12957,15 +12954,7 @@ ix86_compute_frame_layout (void) > gcc_assert (!frame->nsseregs); > > m->call_ms2sysv_pad_in = !!(offset & UNITS_PER_WORD); > - > - /* Select an appropriate layout for incoming stack offset. */ > - const struct xlogue_layout &xlogue = xlogue_layout::get_instance (); > - > - if ((offset + xlogue.get_stack_space_used ()) & UNITS_PER_WORD) > - m->call_ms2sysv_pad_out = 1; > - > - offset += xlogue.get_stack_space_used (); > - gcc_assert (!(offset & 0xf)); > + offset += xlogue_layout::get_instance ().get_stack_space_used (); > } > > /* Align and set SSE register save area. */ > @@ -12993,6 +12982,7 @@ ix86_compute_frame_layout (void) > > /* Align start of frame for local function. */ > if (stack_realign_fp > + || m->call_ms2sysv > || offset != frame->sse_reg_save_offset > || size != 0 > || !crtl->is_leaf > diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h > index 1648bdf1556..b08e45f68d4 100644 > --- a/gcc/config/i386/i386.h > +++ b/gcc/config/i386/i386.h > @@ -2646,17 +2646,13 @@ struct GTY(()) machine_function { > BOOL_BITFIELD arg_reg_available : 1; > > /* If true, we're out-of-lining reg save/restore for regs clobbered > - by ms_abi functions calling a sysv function. */ > + by 64-bit ms_abi functions calling a sysv_abi function. */ > BOOL_BITFIELD call_ms2sysv : 1; > > /* If true, the incoming 16-byte aligned stack has an offset (of 8) and > - needs padding. */ > + needs padding prior to out-of-line stub save/restore area. */ > BOOL_BITFIELD call_ms2sysv_pad_in : 1; > > - /* If true, the size of the stub save area plus inline int reg saves will > - result in an 8 byte offset, so needs padding. */ > - BOOL_BITFIELD call_ms2sysv_pad_out : 1; > - > /* This is the number of extra registers saved by stub (valid range is > 0-6). Each additional register is only saved/restored by the stubs > if all successive ones are. (Will always be zero when using a hard > -- > 2.13.3 >