From 98df3ab0d97ec879ecc5bf0edf8bc0dae724e8e0 Mon Sep 17 00:00:00 2001 From: Daniel Santos Date: Tue, 31 Oct 2017 21:48:55 +0000 Subject: [PATCH] PR target/82002 Part 1: Correct ICE caused by wrong calculation gcc: config/i386/i386.c (ix86_expand_epilogue): Correct stack calculation. gcc/testsuite: gcc.target/i386/pr82002-1.c: New test. gcc.target/i386/pr82002-2a.c: New xfail test. gcc.target/i386/pr82002-2b.c: New xfail test. From-SVN: r254284 --- gcc/ChangeLog | 5 +++++ gcc/config/i386/i386.c | 2 +- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gcc.target/i386/pr82002-1.c | 12 ++++++++++++ gcc/testsuite/gcc.target/i386/pr82002-2a.c | 14 ++++++++++++++ gcc/testsuite/gcc.target/i386/pr82002-2b.c | 14 ++++++++++++++ 6 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr82002-1.c create mode 100644 gcc/testsuite/gcc.target/i386/pr82002-2a.c create mode 100644 gcc/testsuite/gcc.target/i386/pr82002-2b.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 689b5ab3711..62f81b70b9b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2017-10-31 Daniel Santos + + config/i386/i386.c (ix86_expand_epilogue): Correct stack + calculation. + 2017-10-31 Martin Jambor PR c++/81702 diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 382635f4fc7..56c59e991e3 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -13812,7 +13812,7 @@ ix86_expand_epilogue (int style) the stack pointer, if we will restore SSE regs via sp. */ if (TARGET_64BIT && m->fs.sp_offset > 0x7fffffff - && sp_valid_at (frame.stack_realign_offset) + && sp_valid_at (frame.stack_realign_offset + 1) && (frame.nsseregs + frame.nregs) != 0) { pro_epilogue_adjust_stack (stack_pointer_rtx, stack_pointer_rtx, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 82fd2aa7495..68c4b2651a5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2017-10-31 Daniel Santos + + gcc.target/i386/pr82002-1.c: New test. + gcc.target/i386/pr82002-2a.c: New xfail test. + gcc.target/i386/pr82002-2b.c: New xfail test. + 2017-10-31 Martin Jambor PR c++/81702 diff --git a/gcc/testsuite/gcc.target/i386/pr82002-1.c b/gcc/testsuite/gcc.target/i386/pr82002-1.c new file mode 100644 index 00000000000..86678a01992 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr82002-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile { target lp64 } } */ +/* { dg-options "-Ofast -mstackrealign -mabi=ms" } */ + +void a (char *); +void +b () +{ + char c[10000000000]; + c[1099511627776] = 'b'; + a (c); + a (c); +} diff --git a/gcc/testsuite/gcc.target/i386/pr82002-2a.c b/gcc/testsuite/gcc.target/i386/pr82002-2a.c new file mode 100644 index 00000000000..bc85080ba8e --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr82002-2a.c @@ -0,0 +1,14 @@ +/* { dg-do compile { target lp64 } } */ +/* { dg-options "-Ofast -mstackrealign -mabi=ms" } */ +/* { dg-xfail-if "" { *-*-* } } */ +/* { dg-xfail-run-if "" { *-*-* } } */ + +void __attribute__((sysv_abi)) a (char *); +void +b () +{ + char c[10000000000]; + c[1099511627776] = 'b'; + a (c); + a (c); +} diff --git a/gcc/testsuite/gcc.target/i386/pr82002-2b.c b/gcc/testsuite/gcc.target/i386/pr82002-2b.c new file mode 100644 index 00000000000..10e44cd7b1d --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr82002-2b.c @@ -0,0 +1,14 @@ +/* { dg-do compile { target lp64 } } */ +/* { dg-options "-Ofast -mstackrealign -mabi=ms -mcall-ms2sysv-xlogues" } */ +/* { dg-xfail-if "" { *-*-* } } */ +/* { dg-xfail-run-if "" { *-*-* } } */ + +void __attribute__((sysv_abi)) a (char *); +void +b () +{ + char c[10000000000]; + c[1099511627776] = 'b'; + a (c); + a (c); +} -- 2.30.2