From: Uros Bizjak Date: Mon, 8 Jun 2015 20:59:07 +0000 (+0200) Subject: backport: re PR target/66275 (__attribute__((sysv_abi)) with x86_64-w64-mingw32-gcc... X-Git-Tag: releases/gcc-4.8.5~81 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cd8ab29bd97a46fa4b6a0eea1452c4da419c979a;p=thirdparty%2Fgcc.git backport: re PR target/66275 (__attribute__((sysv_abi)) with x86_64-w64-mingw32-gcc generates incorrect code) Backport from mainline: 2015-06-03 Uros Bizjak PR target/66275 * config/i386/i386.c (ix86_function_arg_regno): Use ix86_cfun_abi to determine current function ABI. (ix86_function_value_regno_p): Ditto. testsuite/ChangeLog: Backport from mainline: 2015-06-03 Uros Bizjak PR target/66275 * gcc.target/i386/pr66275.c: New test. From-SVN: r224249 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 97d90074cf77..1f6492fee294 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2015-06-08 Uros Bizjak + + Backport from mainline: + 2015-06-03 Uros Bizjak + + PR target/66275 + * config/i386/i386.c (ix86_function_arg_regno): Use ix86_cfun_abi + to determine current function ABI. + (ix86_function_value_regno_p): Ditto. + 2015-06-05 Venkataramanan Kumar * config/i386/sse.md (sse3_mwait): Swap the operand constriants. diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index cb5b325183c8..c2d0c5fae795 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -5451,6 +5451,7 @@ bool ix86_function_arg_regno_p (int regno) { int i; + enum calling_abi call_abi; const int *parm_regs; if (!TARGET_64BIT) @@ -5481,16 +5482,18 @@ ix86_function_arg_regno_p (int regno) /* TODO: The function should depend on current function ABI but builtins.c would need updating then. Therefore we use the default ABI. */ + call_abi = ix86_cfun_abi (); /* RAX is used as hidden argument to va_arg functions. */ - if (ix86_abi == SYSV_ABI && regno == AX_REG) + if (call_abi == SYSV_ABI && regno == AX_REG) return true; - if (ix86_abi == MS_ABI) + if (call_abi == MS_ABI) parm_regs = x86_64_ms_abi_int_parameter_registers; else parm_regs = x86_64_int_parameter_registers; - for (i = 0; i < (ix86_abi == MS_ABI + + for (i = 0; i < (call_abi == MS_ABI ? X86_64_MS_REGPARM_MAX : X86_64_REGPARM_MAX); i++) if (regno == parm_regs[i]) return true; @@ -7250,7 +7253,7 @@ ix86_function_value_regno_p (const unsigned int regno) return true; case DI_REG: case SI_REG: - return TARGET_64BIT && ix86_abi != MS_ABI; + return TARGET_64BIT && ix86_cfun_abi () != MS_ABI; /* Complex values are returned in %st(0)/%st(1) pair. */ case ST0_REG: @@ -7258,7 +7261,7 @@ ix86_function_value_regno_p (const unsigned int regno) /* TODO: The function should depend on current function ABI but builtins.c would need updating then. Therefore we use the default ABI. */ - if (TARGET_64BIT && ix86_abi == MS_ABI) + if (TARGET_64BIT && ix86_cfun_abi () == MS_ABI) return false; return TARGET_FLOAT_RETURNS_IN_80387; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c4183511c296..576bcb30cbc7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2015-06-08 Uros Bizjak + + Backport from mainline: + 2015-06-03 Uros Bizjak + + PR target/66275 + * gcc.target/i386/pr66275.c: New test. + 2015-06-04 Richard Biener PR middle-end/66251 diff --git a/gcc/testsuite/gcc.target/i386/pr66275.c b/gcc/testsuite/gcc.target/i386/pr66275.c new file mode 100644 index 000000000000..b8759aeb5ec3 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr66275.c @@ -0,0 +1,8 @@ +/* { dg-do compile { target { *-*-linux* && { ! ia32 } } } } */ +/* { dg-options "-mabi=ms -fdump-rtl-dfinit" } */ + +void +__attribute__((sysv_abi)) +foo () {}; + +/* { dg-final { scan-rtl-dump "entry block defs\[^\\n]*\\\[si\\]\[^\\n]*\\\[di\\]" "dfinit" } } */