From d6d1fdcf953a79d1e3ef2d28c99c1933d1e07d80 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 22 Nov 2024 11:33:34 +0100 Subject: [PATCH] i386: Make __builtin_ia32_f{nstenv,ldenv,nstsw,fnclex} builtins internal [PR117165] As the comment says, these builtins are meant to be internal for the atomic support and cause various ICEs when using them directly in various conditions. So the following patch makes them internal. We do have also internal-fn.*, but those target specific builtins would need to be there in generic code, so I've just added space to their name, which is the old way to hide builtins/attributes etc. 2024-11-22 Jakub Jelinek PR target/117165 * config/i386/i386-builtin.def (IX86_BUILTIN_FNSTENV, IX86_BUILTIN_FLDENV, IX86_BUILTIN_FNSTSW, IX86_BUILTIN_FNCLEX): Add space to the end of the builtin name to make it really internal. * gcc.target/i386/pr117165.c: New test. --- gcc/config/i386/i386-builtin.def | 8 +++---- gcc/testsuite/gcc.target/i386/pr117165.c | 27 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr117165.c diff --git a/gcc/config/i386/i386-builtin.def b/gcc/config/i386/i386-builtin.def index 26c23780b1c..d4fa87cb476 100644 --- a/gcc/config/i386/i386-builtin.def +++ b/gcc/config/i386/i386-builtin.def @@ -94,10 +94,10 @@ BDESC (0, 0, CODE_FOR_nothing, "__builtin_ia32_rdpmc", IX86_BUILTIN_RDPMC, UNKNO BDESC (0, 0, CODE_FOR_pause, "__builtin_ia32_pause", IX86_BUILTIN_PAUSE, UNKNOWN, (int) VOID_FTYPE_VOID) /* 80387 (for use internally for atomic compound assignment). */ -BDESC (0, 0, CODE_FOR_fnstenv, "__builtin_ia32_fnstenv", IX86_BUILTIN_FNSTENV, UNKNOWN, (int) VOID_FTYPE_PVOID) -BDESC (0, 0, CODE_FOR_fldenv, "__builtin_ia32_fldenv", IX86_BUILTIN_FLDENV, UNKNOWN, (int) VOID_FTYPE_PCVOID) -BDESC (0, 0, CODE_FOR_fnstsw, "__builtin_ia32_fnstsw", IX86_BUILTIN_FNSTSW, UNKNOWN, (int) USHORT_FTYPE_VOID) -BDESC (0, 0, CODE_FOR_fnclex, "__builtin_ia32_fnclex", IX86_BUILTIN_FNCLEX, UNKNOWN, (int) VOID_FTYPE_VOID) +BDESC (0, 0, CODE_FOR_fnstenv, "__builtin_ia32_fnstenv ", IX86_BUILTIN_FNSTENV, UNKNOWN, (int) VOID_FTYPE_PVOID) +BDESC (0, 0, CODE_FOR_fldenv, "__builtin_ia32_fldenv ", IX86_BUILTIN_FLDENV, UNKNOWN, (int) VOID_FTYPE_PCVOID) +BDESC (0, 0, CODE_FOR_fnstsw, "__builtin_ia32_fnstsw ", IX86_BUILTIN_FNSTSW, UNKNOWN, (int) USHORT_FTYPE_VOID) +BDESC (0, 0, CODE_FOR_fnclex, "__builtin_ia32_fnclex ", IX86_BUILTIN_FNCLEX, UNKNOWN, (int) VOID_FTYPE_VOID) /* MMX */ BDESC (OPTION_MASK_ISA_MMX, 0, CODE_FOR_mmx_emms, "__builtin_ia32_emms", IX86_BUILTIN_EMMS, UNKNOWN, (int) VOID_FTYPE_VOID) diff --git a/gcc/testsuite/gcc.target/i386/pr117165.c b/gcc/testsuite/gcc.target/i386/pr117165.c new file mode 100644 index 00000000000..d1f9663eb33 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr117165.c @@ -0,0 +1,27 @@ +/* PR target/117165 */ +/* { dg-do compile } */ +/* { dg-options "-msoft-float" } */ + +void +foo () +{ + __builtin_ia32_fnstsw (); /* { dg-error "implicit declaration of function" } */ +} + +void +bar () +{ + __builtin_ia32_fnclex (); /* { dg-error "implicit declaration of function" } */ +} + +void +baz () +{ + __builtin_ia32_fnstenv (0); /* { dg-error "implicit declaration of function" } */ +} + +void +qux () +{ + __builtin_ia32_fldenv (0); /* { dg-error "implicit declaration of function" } */ +}