From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 56601 invoked by alias); 27 Apr 2017 08:04:54 -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 56583 invoked by uid 89); 27 Apr 2017 08:04:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.3 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:3566 X-HELO: sasl.smtp.pobox.com Received: from pb-smtp2.pobox.com (HELO sasl.smtp.pobox.com) (64.147.108.71) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 27 Apr 2017 08:04:51 +0000 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 485B588390; Thu, 27 Apr 2017 04:04:52 -0400 (EDT) Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 3FEA28838F; Thu, 27 Apr 2017 04:04:52 -0400 (EDT) Received: from localhost.localdomain (unknown [76.215.41.237]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id 766F48838D; Thu, 27 Apr 2017 04:04:51 -0400 (EDT) From: Daniel Santos To: gcc-patches , Uros Bizjak , Jan Hubicka Subject: [PATCH 01/12] [i386] Re-align stack frame prior to SSE saves. Date: Thu, 27 Apr 2017 08:05:00 -0000 Message-Id: <20170427080932.11703-1-daniel.santos@pobox.com> In-Reply-To: <49e81c0b-07a4-22df-d7c3-2439177ac7cf@pobox.com> References: <49e81c0b-07a4-22df-d7c3-2439177ac7cf@pobox.com> X-Pobox-Relay-ID: 30DE448C-2B20-11E7-A27F-C260AE2156B6-06139138!pb-smtp2.pobox.com X-IsSubscribed: yes X-SW-Source: 2017-04/txt/msg01342.txt.bz2 Add new fields to struct ix86_frame to track where we started the stack re-alignment and what we need to allocate prior to re-alignment. In ix86_compute_frame_layout, we do the stack frame re-alignment computation prior to computing the SSE save area so that it we have an aligned SSE save area. This new also assures that the SSE save area is properly aligned when DRAP is used. Signed-off-by: Daniel Santos --- gcc/config/i386/i386.c | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index d9856573db7..31f69c92968 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -2455,7 +2455,7 @@ struct GTY(()) stack_local_entry { [saved regs] <- regs_save_offset [padding0] - + <- stack_realign_offset [saved SSE regs] <- sse_regs_save_offset [padding1] | @@ -2481,6 +2481,8 @@ struct ix86_frame HOST_WIDE_INT stack_pointer_offset; HOST_WIDE_INT hfp_save_offset; HOST_WIDE_INT reg_save_offset; + HOST_WIDE_INT stack_realign_allocate_offset; + HOST_WIDE_INT stack_realign_offset; HOST_WIDE_INT sse_reg_save_offset; /* When save_regs_using_mov is set, emit prologue using @@ -12636,28 +12638,36 @@ ix86_compute_frame_layout (struct ix86_frame *frame) if (TARGET_SEH) frame->hard_frame_pointer_offset = offset; + /* When re-aligning the stack frame, but not saving SSE registers, this + is the offset we want adjust the stack pointer to. */ + frame->stack_realign_allocate_offset = offset; + + /* The re-aligned stack starts here. Values before this point are not + directly comparable with values below this point. Use sp_valid_at + to determine if the stack pointer is valid for a given offset and + fp_valid_at for the frame pointer. */ + if (stack_realign_fp) + offset = ROUND_UP (offset, stack_alignment_needed); + frame->stack_realign_offset = offset; + /* Align and set SSE register save area. */ if (frame->nsseregs) { /* The only ABI that has saved SSE registers (Win64) also has a - 16-byte aligned default stack, and thus we don't need to be - within the re-aligned local stack frame to save them. In case - incoming stack boundary is aligned to less than 16 bytes, - unaligned move of SSE register will be emitted, so there is - no point to round up the SSE register save area outside the - re-aligned local stack frame to 16 bytes. */ - if (ix86_incoming_stack_boundary >= 128) + 16-byte aligned default stack. However, many programs violate + the ABI, and Wine64 forces stack realignment to compensate. + + If the incoming stack boundary is at least 16 bytes, or DRAP is + required and the DRAP re-alignment boundary is at least 16 bytes, + then we want the SSE register save area properly aligned. */ + if (ix86_incoming_stack_boundary >= 128 + || (stack_realign_drap && stack_alignment_needed >= 16)) offset = ROUND_UP (offset, 16); offset += frame->nsseregs * 16; + frame->stack_realign_allocate_offset = offset; } - frame->sse_reg_save_offset = offset; - /* The re-aligned stack starts here. Values before this point are not - directly comparable with values below this point. In order to make - sure that no value happens to be the same before and after, force - the alignment computation below to add a non-zero value. */ - if (stack_realign_fp) - offset = ROUND_UP (offset, stack_alignment_needed); + frame->sse_reg_save_offset = offset; /* Va-arg area */ frame->va_arg_size = ix86_varargs_gpr_size + ix86_varargs_fpr_size; -- 2.11.0