On Tue, Oct 31, 2017 at 3:09 AM, Daniel Santos <daniel.san...@pobox.com> wrote: > This is a residual problem caused by the off-by-one error in sp_valid_at > and fp_valid_at originally corrected in r252099. However, adding tests > that include an ms_abi to sysv_abi call reveals an additional, more > complex problem with an invalid INSN due to overflowing the s32 offset. > Therefore I'm including all new tests, but marking ones that are broken > by this additional problem as xfail and addressing that in the next > patch. > > 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.
I'd rather see these two xfailed tests committed in the second part, but your approach is also OK. OK for mainline. Thanks, Uros. > Signed-off-by: Daniel Santos <daniel.san...@pobox.com> > --- > gcc/config/i386/i386.c | 2 +- > 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 ++++++++++++++ > 4 files changed, 41 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/config/i386/i386.c b/gcc/config/i386/i386.c > index 2de0dd0c283..83a07afb3e1 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/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.14.3 >