From patchwork Tue Nov 30 09:23:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 48273 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 08264385803D for ; Tue, 30 Nov 2021 09:24:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 08264385803D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1638264250; bh=Gx6ytr1zk+UKgFwHoFmwj2FONJ9HoS5kFTQCp/skpr4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=r/W0oJrgKg1+E4db/27iVQ9Sln2vmWfkIc4CDncmyCvNBDE7p2AyauQX+SY2y/Eg/ VlAZH1jqewVML0hi9xIehSSDKUNzRqtS1fnujCurz+FgaNZ6b0j8tDN/7p79sm5XfX DGBcuHTznk6ELODn9ym5Q95tZoSf2Yq67IhUoZpo= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by sourceware.org (Postfix) with ESMTPS id 359D9385AC22 for ; Tue, 30 Nov 2021 09:23:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 359D9385AC22 Received: by mail-wr1-x42f.google.com with SMTP id u1so42835921wru.13 for ; Tue, 30 Nov 2021 01:23:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=Gx6ytr1zk+UKgFwHoFmwj2FONJ9HoS5kFTQCp/skpr4=; b=fjVHesIaCqq20EYRvo2hVWgVZp0FX383NcMd31mD42oM4mqQ0w87fnbfw/tYwwUi8X +yRArzfIr19bsYY9ephVmmA/nEK5hJn+jGq1QeH0jNB6lWXEjnLzgBjHCvSxVe+hGUiD Da9XlZfakjPoImc1d7pHBMHps4GyoW3+mBtl37Letwt/0xs9LXOxjgIWX7VQFvuDAgTX lRgJevDZbvp2v2LhNEyKU68UdlonLqrIvXB1f6ZUICuFZptK/BVQz4Uzr3eF8swwIgu9 kGp8NgOIywgo/jsyOMLk/dggE8xGKskiRM/ZxJ5I67RjL91p+PDzK2lcJizQjdxf6X0e WD/A== X-Gm-Message-State: AOAM531aluB59Yvn6Hq/0xHpq5VZuBFzEoZJ1fNXcLK/ohnJVCaI9Arg u/qC3bGg4ShCbhplEB3WfoOjgnbaFmC8vA== X-Google-Smtp-Source: ABdhPJwO9MR42UIuCuqbnVNebGFaiiOtk+WHZ029vOdH7lTDg72DVFehL2gd2SucAMkGQz9OBDKzLw== X-Received: by 2002:adf:eb42:: with SMTP id u2mr40847594wrn.521.1638264218270; Tue, 30 Nov 2021 01:23:38 -0800 (PST) Received: from fomalhaut.localnet ([2a01:e0a:41b:84f0:cf71:f5e0:b050:bede]) by smtp.gmail.com with ESMTPSA id g13sm21519928wrd.57.2021.11.30.01.23.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Nov 2021 01:23:37 -0800 (PST) X-Google-Original-From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: Fix PR target/103274 Date: Tue, 30 Nov 2021 10:23:26 +0100 Message-ID: <2084987.irdbgypaU6@fomalhaut> MIME-Version: 1.0 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Eric Botcazou via Gcc-patches From: Eric Botcazou Reply-To: Eric Botcazou Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This fixes a thinko in my fix for the -freorder-blocks-and-partition glitch with SEH on 64-bit Windows: https://gcc.gnu.org/pipermail/gcc-patches/2021-February/565208.html Even if no exceptions are active, e.g. in C, we always need to consider calls. Tested on x86-64/Windows, applied on mainline, 11 and 10 branches as obvious. 2021-11-30 Eric Botcazou PR target/103274 * config/i386/i386.c (ix86_output_call_insn): Beef up comment about nops emitted with SEH. * config/i386/winnt.c (i386_pe_seh_unwind_emit): When switching to the cold section, emit a nop before the directive if the previous active instruction is a call. diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 2657e7817ae..0e6bf3e0fef 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -16438,8 +16438,10 @@ ix86_output_call_insn (rtx_insn *insn, rtx call_op) break; /* If we get to the epilogue note, prevent a catch region from - being adjacent to the standard epilogue sequence. If non- - call-exceptions, we'll have done this during epilogue emission. */ + being adjacent to the standard epilogue sequence. Note that, + if non-call exceptions are enabled, we already did it during + epilogue expansion, or else, if the insn can throw internally, + we already did it during the reorg pass. */ if (NOTE_P (i) && NOTE_KIND (i) == NOTE_INSN_EPILOGUE_BEG && !flag_non_call_exceptions && !can_throw_internal (insn)) diff --git a/gcc/config/i386/winnt.c b/gcc/config/i386/winnt.c index 7c0ea4f731c..0aaf46f050a 100644 --- a/gcc/config/i386/winnt.c +++ b/gcc/config/i386/winnt.c @@ -1243,9 +1243,9 @@ i386_pe_seh_unwind_emit (FILE *out_file, rtx_insn *insn) seh = cfun->machine->seh; if (NOTE_P (insn) && NOTE_KIND (insn) == NOTE_INSN_SWITCH_TEXT_SECTIONS) { - /* See ix86_seh_fixup_eh_fallthru for the rationale. */ + /* See ix86_output_call_insn/seh_fixup_eh_fallthru for the rationale. */ rtx_insn *prev = prev_active_insn (insn); - if (prev && !insn_nothrow_p (prev)) + if (prev && (CALL_P (prev) || !insn_nothrow_p (prev))) fputs ("\tnop\n", out_file); fputs ("\t.seh_endproc\n", out_file); seh->in_cold_section = true;