From patchwork Fri Mar 9 09:07:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 883515 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-474482-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="d4IVLGwk"; 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 3zyM4g5nHVz9sfb for ; Fri, 9 Mar 2018 20:08:50 +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:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=j36Qpa8zGET63lZs s/IVP6BWfli9BvypJWBjBQu+lDxt8i9IKsKIZyjAmvY43yhx7OA8RFn01N7IyXeo LhvZBAFSz8btO9SXAKaf0geVT5OMBSdj2nLd7hwhulKfuIzO3pigdNI9Q7kuNppP 1Dx3nDK1Lo73Lui/4bCvhWGeAXE= 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:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=Ra0W9Ae8Lp5E+ZV/PEkJyM 6WI3M=; b=d4IVLGwklkNN3Nmjgb5bvbpG8MAY0xnBWKF/84EWEclI4kGzN9OSOR FhtafmM+sknbTG9KE2YFAVJiKDycSHoP92bn9UOgQTk8lWqywlanePIWzHRkaLZ6 VZVJRaBBxx3w1A+RpBZnIfU0oVeHwuPfoBM+w10VJDn2gFLhKLCWM= Received: (qmail 24322 invoked by alias); 9 Mar 2018 09:08:43 -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 24307 invoked by uid 89); 9 Mar 2018 09:08:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 09 Mar 2018 09:08:40 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 7F13A81396 for ; Fri, 9 Mar 2018 10:08:38 +0100 (CET) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MsZqGnziN-pp for ; Fri, 9 Mar 2018 10:08:38 +0100 (CET) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 3F42181393 for ; Fri, 9 Mar 2018 10:08:38 +0100 (CET) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: Fix PR target/84763 Date: Fri, 09 Mar 2018 10:07:42 +0100 Message-ID: <1866458.YVN6egk9NU@polaris> MIME-Version: 1.0 This is a small regression just introduced on the mainline by my patch fixing the -freorder-blocks-and-partition optimization on x86-64/Windows. On this platform, the SEH scheme imposes constraints on the prologue of functions, in particular the frame pointer is near the bottom of the frame. But there is an exception when __builtin_{frame,return}_address is present in the code and the implementation of i386_pe_seh_cold_init fails to account for it. Tested on x86-64/Windows, applied on the mainline as obvious. 2018-03-09 Eric Botcazou PR target/84763 * config/i386/winnt.c (i386_pe_seh_cold_init): Use small pre-allocation when the function accesses prior frames. 2018-03-09 Eric Botcazou * gcc.c-torture/compile/20180309-1.c: New test. Index: config/i386/winnt.c =================================================================== --- config/i386/winnt.c (revision 258338) +++ config/i386/winnt.c (working copy) @@ -879,7 +879,7 @@ void i386_pe_seh_cold_init (FILE *f, const char *name) { struct seh_frame_state *seh; - HOST_WIDE_INT offset; + HOST_WIDE_INT alloc_offset, offset; if (!TARGET_SEH) return; @@ -891,7 +891,16 @@ i386_pe_seh_cold_init (FILE *f, const ch assemble_name (f, name); fputc ('\n', f); - offset = seh->sp_offset - INCOMING_FRAME_SP_OFFSET; + /* In the normal case, the frame pointer is near the bottom of the frame + so we can do the full stack allocation and set it afterwards. There + is an exception when the function accesses prior frames so, in this + case, we need to pre-allocate a small chunk before setting it. */ + if (crtl->accesses_prior_frames) + alloc_offset = seh->cfa_offset; + else + alloc_offset = seh->sp_offset; + + offset = alloc_offset - INCOMING_FRAME_SP_OFFSET; if (offset > 0 && offset < SEH_MAX_FRAME_SIZE) fprintf (f, "\t.seh_stackalloc\t" HOST_WIDE_INT_PRINT_DEC "\n", offset); @@ -903,12 +912,12 @@ i386_pe_seh_cold_init (FILE *f, const ch : (gcc_unreachable (), "")), f); print_reg (gen_rtx_REG (DImode, regno), 0, f); fprintf (f, ", " HOST_WIDE_INT_PRINT_DEC "\n", - seh->sp_offset - seh->reg_offset[regno]); + alloc_offset - seh->reg_offset[regno]); } if (seh->cfa_reg != stack_pointer_rtx) { - offset = seh->sp_offset - seh->cfa_offset; + offset = alloc_offset - seh->cfa_offset; gcc_assert ((offset & 15) == 0); gcc_assert (IN_RANGE (offset, 0, 240)); @@ -918,6 +927,13 @@ i386_pe_seh_cold_init (FILE *f, const ch fprintf (f, ", " HOST_WIDE_INT_PRINT_DEC "\n", offset); } + if (crtl->accesses_prior_frames) + { + offset = seh->sp_offset - alloc_offset; + if (offset > 0 && offset < SEH_MAX_FRAME_SIZE) + fprintf (f, "\t.seh_stackalloc\t" HOST_WIDE_INT_PRINT_DEC "\n", offset); + } + fputs ("\t.seh_endprologue\n", f); }