x86: Define _serialize as macro
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 9 Apr 2021 18:44:32 +0000 (11:44 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Sat, 10 Apr 2021 12:59:09 +0000 (05:59 -0700)
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
gcc/testsuite/gcc.target/i386/pr99744-2.c [new file with mode: 0644]

index 89b5b94..e280250 100644 (file)
 #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 (file)
index 0000000..9cbefb0
--- /dev/null
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mserialize" } */
+
+#include <x86intrin.h>
+
+__attribute__ ((target("general-regs-only")))
+void
+foo1 (void)
+{
+  _serialize ();
+}