From patchwork Wed Jun 13 11:23:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 928829 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-479627-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="nynLjF/W"; 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 415PYl49lcz9s2g for ; Wed, 13 Jun 2018 21:25:15 +1000 (AEST) 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=hvTXWTW9dce2z6by NSCAXH5bmFHoV4QywM2++kPlmHUl04kH/6d0u4CH0dHvkunWRZt9ZJX17ARNtCOh th2JMGeiVReK2SFGXKqFmfJxljpgSvowFs+QWZ6wpNnrxjDFw9Rmz+avYd4cpXfJ W/hMHg6pglinbLjtLfgjFWy3yik= 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=Od8yCmkh0r1jLYsJYZQ62M JrRwg=; b=nynLjF/W7KGHb72Q6a36LZD6ouuvq5HmDN86Nv0I8TG2XZg/GshWVg mpdKdV7by4xS52GhJgYF2Z4gpVIorArvXcukeergA2JsLUteSlwPn2W35KuuP4Sh Phb3DbKMhcsWpouubrVecYeCz6LHSY+TP+Ptp/O5Zy4JTCCB2p4Uc= Received: (qmail 71984 invoked by alias); 13 Jun 2018 11:25:00 -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 71822 invoked by uid 89); 13 Jun 2018 11:24:51 -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, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=ebotcazouadacorecom, ebotcazou@adacore.com, HContent-Transfer-Encoding:7Bit 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; Wed, 13 Jun 2018 11:24:48 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id EEE7A81549 for ; Wed, 13 Jun 2018 13:24:45 +0200 (CEST) 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 y9xRecrspTr2 for ; Wed, 13 Jun 2018 13:24:45 +0200 (CEST) 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 CA6CD8137F for ; Wed, 13 Jun 2018 13:24:45 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: Fix PR target/86048 Date: Wed, 13 Jun 2018 13:23:41 +0200 Message-ID: <4512915.JhvSi1tPVi@polaris> MIME-Version: 1.0 This is a follow-up to PR target/84763 present on mainline and 8 branch: https://gcc.gnu.org/ml/gcc-patches/2018-03/msg00418.html Since i386_pe_seh_cold_init now uses a small pre-allocation when there is __builtin_{frame,return}_address in the function, it also may need to split CFI save directives (.seh_savexmm/.seh_savereg) into a first group emitted after the pre-allocation and the rest emitted after the full allocation. Tested on x86-64/Windows, applied on the mainline and 8 branch as obvious. 2018-06-13 Eric Botcazou PR target/86048 * config/i386/winnt.c (i386_pe_seh_cold_init): Do not emit negative offsets for register save directives. Emit a second batch of save directives, if need be, when the function accesses prior frames. 2018-06-13 Eric Botcazou * gcc.target/i386/pr86048.c: New test. Index: config/i386/winnt.c =================================================================== --- config/i386/winnt.c (revision 261473) +++ config/i386/winnt.c (working copy) @@ -922,11 +922,14 @@ i386_pe_seh_cold_init (FILE *f, const ch fprintf (f, "\t.seh_stackalloc\t" HOST_WIDE_INT_PRINT_DEC "\n", offset); for (int regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++) - if (seh->reg_offset[regno] > 0) + if (seh->reg_offset[regno] > 0 && seh->reg_offset[regno] <= alloc_offset) { - fputs ((SSE_REGNO_P (regno) ? "\t.seh_savexmm\t" - : GENERAL_REGNO_P (regno) ? "\t.seh_savereg\t" - : (gcc_unreachable (), "")), f); + if (SSE_REGNO_P (regno)) + fputs ("\t.seh_savexmm\t", f); + else if (GENERAL_REGNO_P (regno)) + fputs ("\t.seh_savereg\t", f); + else + gcc_unreachable (); print_reg (gen_rtx_REG (DImode, regno), 0, f); fprintf (f, ", " HOST_WIDE_INT_PRINT_DEC "\n", alloc_offset - seh->reg_offset[regno]); @@ -949,6 +952,20 @@ i386_pe_seh_cold_init (FILE *f, const ch 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); + + for (int regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++) + if (seh->reg_offset[regno] > alloc_offset) + { + if (SSE_REGNO_P (regno)) + fputs ("\t.seh_savexmm\t", f); + else if (GENERAL_REGNO_P (regno)) + fputs ("\t.seh_savereg\t", f); + else + gcc_unreachable (); + print_reg (gen_rtx_REG (DImode, regno), 0, f); + fprintf (f, ", " HOST_WIDE_INT_PRINT_DEC "\n", + seh->sp_offset - seh->reg_offset[regno]); + } } fputs ("\t.seh_endprologue\n", f);