On Tue, Mar 30, 2021 at 4:40 AM Uros Bizjak <ubiz...@gmail.com> wrote: > > On Tue, Mar 30, 2021 at 1:03 PM Jakub Jelinek <ja...@redhat.com> wrote: > > > > On Tue, Mar 30, 2021 at 12:59:16PM +0200, Richard Biener wrote: > > > > > > So yes, a better solution would be nice but I can't see any since > > > > > > the > > > > > > underlying issue is known since a long time and thus the pragmatic > > > > > > solution is the best (IMHO), also from a QOI perspective. For > > > > > > intrinsics > > > > > > it also avoids differences with -O0 vs -O with what we accept and > > > > > > reject. > > > > > > > > > > Here is a simple patch for GCC 11 by defining __rdtsc and __rdtscp > > > > > as macros. OK for master? > > > > > > > > I don't want to step on anyone's toes by approving this approach, so > > > > I'd like to ask Richard and Jakub if they agree with the solution. > > > > > > I'm OK with the solution for __rdtsc & friends. > > > > Ok for me too (temporarily until we have a fix for the general problem). > > > > > I suppose there's nothing that guarantees taking the address of an > > > intrinsic is going to work? > > > > I bet one gets tons of different errors that way. After all, for -O0 a lot > > of intrinsics are macros. And, for those that are inline functions, a lot > > of them will be rejected if an immediate argument doesn't have a constant > > value. > > LGTM for the patch. > > Thanks, > Uros.
Here is another one. OK for master? Thanks. -- H.J.
From 3b9fce8c045f9febef4f57253972741dc6305c85 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" <hjl.to...@gmail.com> Date: Fri, 9 Apr 2021 11:44:32 -0700 Subject: [PATCH] x86: Define _serialize as macro Define _serialize as macro for callers with general-regs-only target attribute to avoid inline failure with always_inline attribute. gcc/ PR target/99744 * config/i386/serializeintrin.h (_serialize): Defined as macro. gcc/testsuite/ PR target/99744 * gcc.target/i386/pr99744-2.c: New test. --- gcc/config/i386/serializeintrin.h | 7 +------ gcc/testsuite/gcc.target/i386/pr99744-2.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr99744-2.c diff --git a/gcc/config/i386/serializeintrin.h b/gcc/config/i386/serializeintrin.h index 89b5b94ea9b..e280250b198 100644 --- a/gcc/config/i386/serializeintrin.h +++ b/gcc/config/i386/serializeintrin.h @@ -34,12 +34,7 @@ #define __DISABLE_SERIALIZE__ #endif /* __SERIALIZE__ */ -extern __inline void -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) -_serialize (void) -{ - __builtin_ia32_serialize (); -} +#define _serialize() __builtin_ia32_serialize () #ifdef __DISABLE_SERIALIZE__ #undef __DISABLE_SERIALIZE__ diff --git a/gcc/testsuite/gcc.target/i386/pr99744-2.c b/gcc/testsuite/gcc.target/i386/pr99744-2.c new file mode 100644 index 00000000000..9cbefb04536 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr99744-2.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mserialize" } */ + +#include <x86intrin.h> + +__attribute__ ((target("general-regs-only"))) +void +foo1 (void) +{ + _serialize (); +} -- 2.30.2