Since GCC 8, the -freorder-blocks-and-partition pass can split a function
into hot and cold parts, thus generating 2 CIEs for a single function in
DWARF for exception purposes and doing an equivalent trick for Windows SEH.
Now the Windows system unwinder is picky when it comes to the boundary
between an active EH region and the end of the function and, therefore,
a nop may need to be added in specific cases.
gcc/
* 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 can throw.
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. */
+ rtx_insn *prev = prev_active_insn (insn);
+ if (prev && !insn_nothrow_p (prev))
+ fputs ("\tnop\n", asm_out_file);
fputs ("\t.seh_endproc\n", asm_out_file);
seh->in_cold_section = true;
return;