https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58372
--- Comment #17 from Uroš Bizjak <ubizjak at gmail dot com> --- (In reply to Kai Tietz from comment #16) > > If you want to experiment, try the following patch: > > > > Index: config/i386/mingw32.h > > =================================================================== > > --- config/i386/mingw32.h (revision 265582) > > +++ config/i386/mingw32.h (working copy) > > @@ -251,6 +251,10 @@ > > #undef CHECK_EXECUTE_STACK_ENABLED > > #define CHECK_EXECUTE_STACK_ENABLED flag_setstackexecutable > > > > +#undef PREFERRED_STACK_BOUNDARY_DEFAULT > > +#define PREFERRED_STACK_BOUNDARY_DEFAULT \ > > + (TARGET_64BIT ? 128 : MIN_STACK_BOUNDARY) > > + > > /* This matches SHLIB_SONAME and SHLIB_SOVERSION in t-cygming. */ > > /* This matches SHLIB_SONAME and SHLIB_SOVERSION in t-cygwin. */ > > #if DWARF2_UNWIND_INFO> > > But I don't know the details of MS ABI, so I can't tell if the patch is > > correct. > > The x64 ABI part is correct, as for x64 abit there is just 16-byte stack > alignment. For x86 ms abi things aren't that strict AFAIK. The common stack > alignment on function entry is the natural one, but there is in general no > strict requirement for it. So the patch looks fine, but should be commented > in the release notes, as there might be fallout seen caused by it. Unfortunately, I have no way of testing the patch on windows targets. Please also note that the testcase still ICEs with patched compiler when -mpreferred-stack-bonudary=4 option is used. Based on the comments in emit-rtl.h: /* The largest alignment needed on the stack, including requirement for outgoing stack alignment. */ unsigned int stack_alignment_needed; /* Preferred alignment of the end of stack frame, which is preferred to call other functions. */ unsigned int preferred_stack_boundary; it looks that somewhere stack_alignment_needed should be set to at least the value of preferred_stack_boundary. Just above the assert in i386.c, there is: /* 64-bit MS ABI seem to require stack alignment to be always 16, except for function prologues, leaf functions and when the defult incoming stack boundary is overriden at command line or via force_align_arg_pointer attribute. */ if ((TARGET_64BIT_MS_ABI && crtl->preferred_stack_boundary < 128) && (!crtl->is_leaf || cfun->calls_alloca != 0 || ix86_current_function_calls_tls_descriptor || ix86_incoming_stack_boundary < 128)) { crtl->preferred_stack_boundary = 128; crtl->stack_alignment_needed = 128; } so this maybe hints what to do in x86 case. Perhaps the patch in Comment #8 is the way to go.