From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1285) id 98A4C3858012; Tue, 30 Nov 2021 09:19:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 98A4C3858012 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Eric Botcazou To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-5598] Fix -freorder-blocks-and-partition glitch with Windows SEH (continued) X-Act-Checkin: gcc X-Git-Author: Eric Botcazou X-Git-Refname: refs/heads/master X-Git-Oldrev: 7abcc9ca20d4e17deabb308b5f483aaccc3dc02c X-Git-Newrev: bc8d6c60137f8bbf173b86ddf31b15d7ba2a33dd Message-Id: <20211130091941.98A4C3858012@sourceware.org> Date: Tue, 30 Nov 2021 09:19:41 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Nov 2021 09:19:41 -0000 https://gcc.gnu.org/g:bc8d6c60137f8bbf173b86ddf31b15d7ba2a33dd commit r12-5598-gbc8d6c60137f8bbf173b86ddf31b15d7ba2a33dd Author: Eric Botcazou Date: Tue Nov 30 10:17:09 2021 +0100 Fix -freorder-blocks-and-partition glitch with Windows SEH (continued) This fixes a thinko in the 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 need to consider calls. gcc/ 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: --- gcc/config/i386/i386.c | 6 ++++-- gcc/config/i386/winnt.c | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) 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;