public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-7735] x86: Issue error for return/argument only with function body
@ 2021-03-19 13:40 H.J. Lu
0 siblings, 0 replies; only message in thread
From: H.J. Lu @ 2021-03-19 13:40 UTC (permalink / raw)
To: gcc-cvs
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.
Diff:
---
gcc/config/i386/i386-options.c | 1 +
gcc/config/i386/i386.c | 12 ++++++++++++
gcc/config/i386/i386.h | 4 ++++
gcc/testsuite/gcc.dg/torture/pr99652-1.c | 8 ++++++++
gcc/testsuite/gcc.dg/torture/pr99652-2.c | 8 ++++++++
gcc/testsuite/gcc.target/i386/pr57655.c | 4 ++--
gcc/testsuite/gcc.target/i386/pr59794-6.c | 4 ++--
gcc/testsuite/gcc.target/i386/pr70738-1.c | 4 ++--
gcc/testsuite/gcc.target/i386/pr96744-1.c | 4 ++--
9 files changed, 41 insertions(+), 8 deletions(-)
diff --git a/gcc/config/i386/i386-options.c b/gcc/config/i386/i386-options.c
index 7865bc110a3..b653527d266 100644
--- a/gcc/config/i386/i386-options.c
+++ b/gcc/config/i386/i386-options.c
@@ -1768,6 +1768,7 @@ ix86_init_machine_status (void)
f = ggc_cleared_alloc<machine_function> ();
f->call_abi = ix86_abi;
f->stack_frame_required = true;
+ f->silent_p = true;
return f;
}
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 540d4f44517..714349094bd 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -1705,6 +1705,10 @@ init_cumulative_args (CUMULATIVE_ARGS *cum, /* Argument info to initialize */
struct cgraph_node *local_info_node = NULL;
struct cgraph_node *target = NULL;
+ /* Set silent_p to false to raise an error for invalid calls when
+ expanding function body. */
+ cfun->machine->silent_p = false;
+
memset (cum, 0, sizeof (*cum));
if (fndecl)
@@ -2534,6 +2538,10 @@ construct_container (machine_mode mode, machine_mode orig_mode,
some less clueful developer tries to use floating-point anyway. */
if (needed_sseregs && !TARGET_SSE)
{
+ /* Return early if we shouldn't raise an error for invalid
+ calls. */
+ if (cfun->machine->silent_p)
+ return NULL;
if (in_return)
{
if (!issued_sse_ret_error)
@@ -2558,6 +2566,10 @@ construct_container (machine_mode mode, machine_mode orig_mode,
|| regclass[i] == X86_64_X87UP_CLASS
|| regclass[i] == X86_64_COMPLEX_X87_CLASS)
{
+ /* Return early if we shouldn't raise an error for invalid
+ calls. */
+ if (cfun->machine->silent_p)
+ return NULL;
if (!issued_x87_ret_error)
{
error ("x87 register return with x87 disabled");
diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
index 48749104b24..058c1cc25b2 100644
--- a/gcc/config/i386/i386.h
+++ b/gcc/config/i386/i386.h
@@ -2945,6 +2945,10 @@ struct GTY(()) machine_function {
function. */
BOOL_BITFIELD has_explicit_vzeroupper : 1;
+ /* True if we should act silently, rather than raise an error for
+ invalid calls. */
+ BOOL_BITFIELD silent_p : 1;
+
/* The largest alignment, in bytes, of stack slot actually used. */
unsigned int max_used_stack_alignment;
diff --git a/gcc/testsuite/gcc.dg/torture/pr99652-1.c b/gcc/testsuite/gcc.dg/torture/pr99652-1.c
new file mode 100644
index 00000000000..c2395ff4ed8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr99652-1.c
@@ -0,0 +1,8 @@
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-mgeneral-regs-only" } */
+
+inline double
+foo (void)
+{
+ return 1.0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr99652-2.c b/gcc/testsuite/gcc.dg/torture/pr99652-2.c
new file mode 100644
index 00000000000..beefad8bfee
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr99652-2.c
@@ -0,0 +1,8 @@
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-mno-80387" } */
+
+inline double
+foo (void)
+{
+ return 1.0;
+}
diff --git a/gcc/testsuite/gcc.target/i386/pr57655.c b/gcc/testsuite/gcc.target/i386/pr57655.c
index 33a59d3a263..649cdef832d 100644
--- a/gcc/testsuite/gcc.target/i386/pr57655.c
+++ b/gcc/testsuite/gcc.target/i386/pr57655.c
@@ -2,7 +2,7 @@
/* { dg-options "-mavx -mvzeroupper -mno-fp-ret-in-387" } */
long double
-foo (long double x)
-{ /* { dg-error "x87 register return with x87 disabled" "" { target { ! ia32 } } } */
+foo (long double x) /* { dg-error "x87 register return with x87 disabled" "" { target { ! ia32 } } } */
+{
return __builtin_ilogbl (x);
}
diff --git a/gcc/testsuite/gcc.target/i386/pr59794-6.c b/gcc/testsuite/gcc.target/i386/pr59794-6.c
index c809f957927..babcf76eaf8 100644
--- a/gcc/testsuite/gcc.target/i386/pr59794-6.c
+++ b/gcc/testsuite/gcc.target/i386/pr59794-6.c
@@ -8,7 +8,7 @@ typedef int __v4si __attribute__ ((__vector_size__ (16)));
extern __v4si x;
__v4si
-foo (void)
-{ /* { dg-error "SSE register return with SSE disabled" } */
+foo (void) /* { dg-error "SSE register return with SSE disabled" } */
+{
return x;
}
diff --git a/gcc/testsuite/gcc.target/i386/pr70738-1.c b/gcc/testsuite/gcc.target/i386/pr70738-1.c
index 19381c26932..62d609c9f66 100644
--- a/gcc/testsuite/gcc.target/i386/pr70738-1.c
+++ b/gcc/testsuite/gcc.target/i386/pr70738-1.c
@@ -3,7 +3,7 @@
typedef int int32x2_t __attribute__ ((__vector_size__ ((8))));
-int32x2_t test (int32x2_t a, int32x2_t b)
-{ /* { dg-error "SSE register return with SSE disabled" } */
+int32x2_t test (int32x2_t a, int32x2_t b) /* { dg-error "SSE register return with SSE disabled" } */
+{
return a + b;
}
diff --git a/gcc/testsuite/gcc.target/i386/pr96744-1.c b/gcc/testsuite/gcc.target/i386/pr96744-1.c
index 46f3ce6ddd4..da5557d89b7 100644
--- a/gcc/testsuite/gcc.target/i386/pr96744-1.c
+++ b/gcc/testsuite/gcc.target/i386/pr96744-1.c
@@ -4,7 +4,7 @@
typedef int int32x2_t __attribute__ ((__vector_size__ ((8))));
__attribute__((__target__("general-regs-only")))
-int32x2_t test (int32x2_t a, int32x2_t b)
-{ /* { dg-error "SSE register return with SSE disabled" } */
+int32x2_t test (int32x2_t a, int32x2_t b) /* { dg-error "SSE register return with SSE disabled" } */
+{
return a + b;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-03-19 13:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-19 13:40 [gcc r11-7735] x86: Issue error for return/argument only with function body H.J. Lu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).