From 661c8707bf0629bb1b69efa14dfc3d8e89e61706 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Thu, 9 Jul 2015 09:26:47 +0000 Subject: [PATCH] Check int_size_in_bytes in ix86_return_in_memory ix86_return_in_memory should check negative return from int_size_in_bytes, similar to other ports. gcc/ PR target/66817 * config/i386/i386.c (ix86_return_in_memory): Return true if int_size_in_bytes returns negative for IA MCU. gcc/testsuite/ PR target/66817 * gcc.target/i386/pr66817.c: New test. From-SVN: r225605 --- gcc/ChangeLog | 6 ++++++ gcc/config/i386/i386.c | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.target/i386/pr66817.c | 27 +++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr66817.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a0d835e1efd..78cc6f94553 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-07-09 H.J. Lu + + PR target/66817 + * config/i386/i386.c (ix86_return_in_memory): Return true + if int_size_in_bytes returns negative for IA MCU. + 2015-07-09 Marek Polacek PR tree-optimization/66718 diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 55a32acc581..54ee6f3d4fd 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -8682,7 +8682,7 @@ ix86_return_in_memory (const_tree type, const_tree fntype ATTRIBUTE_UNUSED) /* Intel MCU psABI returns scalars and aggregates no larger than 8 bytes in registers. */ if (TARGET_IAMCU) - return VECTOR_MODE_P (mode) || size > 8; + return VECTOR_MODE_P (mode) || size < 0 || size > 8; if (mode == BLKmode) return true; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 661ccb52de1..42b62031623 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-07-09 H.J. Lu + + PR target/66817 + * gcc.target/i386/pr66817.c: New test. + 2015-07-09 Marek Polacek PR tree-optimization/66718 diff --git a/gcc/testsuite/gcc.target/i386/pr66817.c b/gcc/testsuite/gcc.target/i386/pr66817.c new file mode 100644 index 00000000000..7ec18b74d1c --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr66817.c @@ -0,0 +1,27 @@ +/* { dg-do compile { target ia32 } } */ +/* { dg-options "-O2 -mno-sse -mno-mmx -miamcu" } */ + +extern void abort (void); +int +main (int argc, char **argv) +{ + int size = 10; + typedef struct + { + char val[size]; + } + block; + block a, b; + block __attribute__((noinline)) + retframe_block () + { + return *(block *) &b; + } + b.val[0] = 1; + b.val[9] = 2; + a=retframe_block (); + if (a.val[0] != 1 + || a.val[9] != 2) + abort (); + return 0; +} -- 2.30.2