Bug 99652 - inline doesn't with -mno-sse
Summary: inline doesn't with -mno-sse
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 11.0
: P3 normal
Target Milestone: 11.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-03-18 18:41 UTC by H.J. Lu
Modified: 2021-03-19 13:44 UTC (History)
3 users (show)

See Also:
Host:
Target: x86-64
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-03-18 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2021-03-18 18:41:57 UTC
[hjl@gnu-cfl-2 tmp]$ cat x.c
inline double
foo (void)
{
  return 1.0;
}
[hjl@gnu-cfl-2 tmp]$ gcc -S x.c
[hjl@gnu-cfl-2 tmp]$ cat x.s
	.file	"x.c"
	.text
	.ident	"GCC: (GNU) 10.2.1 20210130 (Red Hat 10.2.1-11)"
	.section	.note.GNU-stack,"",@progbits
[hjl@gnu-cfl-2 tmp]$ gcc -S x.c -mno-sse
x.c: In function ‘foo’:
x.c:3:1: error: SSE register return with SSE disabled
    3 | {
      | ^
[hjl@gnu-cfl-2 tmp]$
Comment 1 Andrew Pinski 2021-03-18 18:48:49 UTC
I don't see why this is a bug. GCC decides the return register early on and that is a good thing.
Comment 2 H.J. Lu 2021-03-18 19:03:02 UTC
(In reply to Andrew Pinski from comment #1)
> I don't see why this is a bug. GCC decides the return register early on and
> that is a good thing.

On arm64, I got

[hjl@gnu-cfl-2 gcc]$ cat /tmp/x.c
inline double
foo (void)
{
  return 1.0;
}
[hjl@gnu-cfl-2 gcc]$ ./xgcc -B./ -mgeneral-regs-only /tmp/x.c -S
[hjl@gnu-cfl-2 gcc]$
Comment 3 Jakub Jelinek 2021-03-18 19:05:09 UTC
Doesn't really matter.  On x86_64 the ABI says that double is returned in a SSE register, so people either can't return floating point types (and pass floating point arguments to functions), or shouldn't disable SSE.
Comment 4 H.J. Lu 2021-03-18 19:09:12 UTC
We run into this with Intel UINTR on <stdlib.h>:

https://sourceware.org/bugzilla/show_bug.cgi?id=27600

We'd like to allow <stdlib.h> with -mgeneral-regs-only.
Comment 5 Uroš Bizjak 2021-03-18 21:14:40 UTC
inline long double
foo (void)
{
  return 1.0;
}
gcc -S -O2 -mno-80387 double.c
double.c: In function ‘foo’:
double.c:3:1: error: x87 register return with x87 disabled
    3 | {
      | ^
Comment 6 GCC Commits 2021-03-19 13:40:06 UTC
The master branch has been updated by H.J. Lu <hjl@gcc.gnu.org>:

https://gcc.gnu.org/g:5e2eabe1eed1e53d39923517122d3c7de2013ad4

commit r11-7735-g5e2eabe1eed1e53d39923517122d3c7de2013ad4
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Mar 18 11:47:46 2021 -0700

    x86: Issue error for return/argument only with function body
    
    If we never generate function body, we shouldn't issue errors for return
    nor argument.  Add silent_p to i386 machine_function to avoid issuing
    errors for return and argument without function body.
    
    gcc/
    
            PR target/99652
            * config/i386/i386-options.c (ix86_init_machine_status): Set
            silent_p to true.
            * config/i386/i386.c (init_cumulative_args): Set silent_p to
            false.
            (construct_container): Return early for return and argument
            errors if silent_p is true.
            * config/i386/i386.h (machine_function): Add silent_p.
    
    gcc/testsuite/
    
            PR target/99652
            * gcc.dg/torture/pr99652-1.c: New test.
            * gcc.dg/torture/pr99652-2.c: Likewise.
            * gcc.target/i386/pr57655.c: Adjusted.
            * gcc.target/i386/pr59794-6.c: Likewise.
            * gcc.target/i386/pr70738-1.c: Likewise.
            * gcc.target/i386/pr96744-1.c: Likewise.
Comment 7 H.J. Lu 2021-03-19 13:44:15 UTC
Fixed for GCC 11.