Created attachment 36539 [details] reduced testcase Compiler output: $ gcc -O -mabi=ms -mstackrealign testcase.c testcase.c: In function 'fn1': testcase.c:7:1: internal compiler error: in ix86_compute_frame_layout, at config/i386/i386.c:11308 } ^ 0xe73ea0 ix86_compute_frame_layout /mnt/svn/gcc-trunk/gcc/config/i386/i386.c:11308 0xe97196 ix86_expand_prologue() /mnt/svn/gcc-trunk/gcc/config/i386/i386.c:12578 0x10453ba gen_prologue() /mnt/svn/gcc-trunk/gcc/config/i386/i386.md:12282 0xe704b8 target_gen_prologue /mnt/svn/gcc-trunk/gcc/config/i386/i386.md:18335 0x89a5af thread_prologue_and_epilogue_insns() /mnt/svn/gcc-trunk/gcc/function.c:5972 0x89b1f2 rest_of_handle_thread_prologue_and_epilogue /mnt/svn/gcc-trunk/gcc/function.c:6523 0x89b1f2 execute /mnt/svn/gcc-trunk/gcc/function.c:6565 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions. $ gcc -v Using built-in specs. COLLECT_GCC=/mnt/svn/gcc-trunk/binary-latest/bin/gcc COLLECT_LTO_WRAPPER=/mnt/svn/gcc-trunk/binary-228793-lto-fortran-checking-yes-rtl-df/libexec/gcc/x86_64-pc-linux-gnu/6.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /mnt/svn/gcc-trunk//configure --enable-checking=yes,rtl,df --enable-languages=c,c++,lto,fortran --prefix=/mnt/svn/gcc-trunk/binary-228793-lto-fortran-checking-yes-rtl-df/ --without-cloog --without-ppl --without-isl Thread model: posix gcc version 6.0.0 20151014 (experimental) (GCC) Tested revisions: r228793 - ICE 5_branch r228441 - OK
Some parts of gcc still assume that MS_ABI stack is always aligned to 128bits. Proposed patch: --cut here-- @@ -11283,7 +11296,8 @@ ix86_compute_frame_layout (struct ix86_frame *fram function prologues and leaf. */ if ((TARGET_64BIT_MS_ABI && crtl->preferred_stack_boundary < 128) && (!crtl->is_leaf || cfun->calls_alloca != 0 - || ix86_current_function_calls_tls_descriptor)) + || ix86_current_function_calls_tls_descriptor + || ix86_incoming_stack_boundary < 128)) { crtl->preferred_stack_boundary = 128; crtl->stack_alignment_needed = 128; --cut here--
I am also seeing this (or another in ix86_compute_frame_layout) ICE when running the gfortran testsuite. Again with -mstackrealing. I will post the testcase when I get home.
(In reply to Zdenek Sojka from comment #2) > I am also seeing this (or another in ix86_compute_frame_layout) ICE when > running the gfortran testsuite. Again with -mstackrealing. I will post the > testcase when I get home. -mstackrealign is a new functionality on MS_ABI targets, and there are some places in the compiler that assume that these targets are always aligned to 16bytes. This alignment is in fact mandated by ABI, and all deviations can be considered ABI violations. However, we can relax this restriction in order to handle rough applications that misalign the stack, but this should in general be an exception, not the rule. That said, even if -mstackrealign can be declared as unsupported on MS_ABI targets, the infrastructure handles realignment just fine also for MS_ABI targets, we just need to enable correct code paths when incoming stack boundary is less than 16 bytes. This is exactly what the patch in comment #1 does. BTW: I'm not in the position to test MS_ABI targets thoroughly, so I'd ask you to please conduct your tests with the patch from Comment #1.
Author: uros Date: Wed Oct 21 08:43:44 2015 New Revision: 229120 URL: https://gcc.gnu.org/viewcvs?rev=229120&root=gcc&view=rev Log: PR target/68018 * config/i386/i386.c (ix86_compute_frame_layout): Realign the stack for 64-bit MS_ABI targets also when default incoming stack boundary is overriden. testsuite/ChangeLog: PR target/68018 * gcc.target/i386/pr68018.c: New test. Added: trunk/gcc/testsuite/gcc.target/i386/pr68018.c Modified: trunk/gcc/ChangeLog trunk/gcc/config/i386/i386.c trunk/gcc/testsuite/ChangeLog
I did a test run with r229094 + the patch applied, and there are no ICEs. All the ICEs archived from older runs are gone, and no new ones are introduced (eg. everything that failed in the past now compiles fine). I can only test for ICEs, not for exec failures.
Author: uros Date: Thu Oct 22 06:52:00 2015 New Revision: 229162 URL: https://gcc.gnu.org/viewcvs?rev=229162&root=gcc&view=rev Log: Backport from mainline 2015-10-21 Uros Bizjak <ubizjak@gmail.com> PR target/68018 * config/i386/i386.c (ix86_compute_frame_layout): Realign the stack for 64-bit MS_ABI targets also when default incoming stack boundary is overriden. testsuite/ChangeLog: Backport from mainline 2015-10-21 Uros Bizjak <ubizjak@gmail.com> PR target/68018 * gcc.target/i386/pr68018.c: New test. Backport from mainline 2015-10-21 Uros Bizjak <ubizjak@gmail.com> PR target/68018 * config/i386/i386.c (ix86_compute_frame_layout): Realign the stack for 64-bit MS_ABI targets also when default incoming stack boundary is overriden. testsuite/ChangeLog: Backport from mainline 2015-10-21 Uros Bizjak <ubizjak@gmail.com> PR target/68018 * gcc.target/i386/pr68018.c: New test. Added: branches/gcc-5-branch/gcc/testsuite/gcc.target/i386/pr68018.c Modified: branches/gcc-5-branch/gcc/ChangeLog branches/gcc-5-branch/gcc/config/i386/i386.c branches/gcc-5-branch/gcc/testsuite/ChangeLog
Fixed.