public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r9-9303] x86: Add __volatile__ to __cpuid and __cpuid_count
@ 2021-03-23 12:51 H.J. Lu
  0 siblings, 0 replies; only message in thread
From: H.J. Lu @ 2021-03-23 12:51 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:66cd00cf21b80ed3dc7678e605555e41b6ac6085

commit r9-9303-g66cd00cf21b80ed3dc7678e605555e41b6ac6085
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Sun Mar 21 19:47:24 2021 -0700

    x86: Add __volatile__ to __cpuid and __cpuid_count
    
    Since CPUID instruction may return different values on hybrid core.
    volatile is needed on asm statements in <cpuid.h>.
    
            PR target/99704
            * config/i386/cpuid.h (__cpuid): Add __volatile__.
            (__cpuid_count): Likewise.
    
    (cherry picked from commit 9c89c9e9c6b59260c7745c8714b69f94784a9c13)

Diff:
---
 gcc/config/i386/cpuid.h | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/gcc/config/i386/cpuid.h b/gcc/config/i386/cpuid.h
index 2775e705c70..e4199422aae 100644
--- a/gcc/config/i386/cpuid.h
+++ b/gcc/config/i386/cpuid.h
@@ -188,28 +188,28 @@
 /* At least one cpu (Winchip 2) does not set %ebx and %ecx
    for cpuid leaf 1. Forcibly zero the two registers before
    calling cpuid as a precaution.  */
-#define __cpuid(level, a, b, c, d)			\
-  do {							\
-    if (__builtin_constant_p (level) && (level) != 1)	\
-      __asm__ ("cpuid\n\t"				\
-	      : "=a" (a), "=b" (b), "=c" (c), "=d" (d)	\
-	      : "0" (level));				\
-    else						\
-      __asm__ ("cpuid\n\t"				\
-	      : "=a" (a), "=b" (b), "=c" (c), "=d" (d)	\
-	      : "0" (level), "1" (0), "2" (0));		\
+#define __cpuid(level, a, b, c, d)					\
+  do {									\
+    if (__builtin_constant_p (level) && (level) != 1)			\
+      __asm__ __volatile__ ("cpuid\n\t"					\
+			    : "=a" (a), "=b" (b), "=c" (c), "=d" (d)	\
+			    : "0" (level));				\
+    else								\
+      __asm__ __volatile__ ("cpuid\n\t"					\
+			    : "=a" (a), "=b" (b), "=c" (c), "=d" (d)	\
+			    : "0" (level), "1" (0), "2" (0));		\
   } while (0)
 #else
-#define __cpuid(level, a, b, c, d)			\
-  __asm__ ("cpuid\n\t"					\
-	   : "=a" (a), "=b" (b), "=c" (c), "=d" (d)	\
-	   : "0" (level))
+#define __cpuid(level, a, b, c, d)					\
+  __asm__ __volatile__ ("cpuid\n\t"					\
+			: "=a" (a), "=b" (b), "=c" (c), "=d" (d)	\
+			: "0" (level))
 #endif
 
-#define __cpuid_count(level, count, a, b, c, d)		\
-  __asm__ ("cpuid\n\t"					\
-	   : "=a" (a), "=b" (b), "=c" (c), "=d" (d)	\
-	   : "0" (level), "2" (count))
+#define __cpuid_count(level, count, a, b, c, d)				\
+  __asm__ __volatile__ ("cpuid\n\t"					\
+			: "=a" (a), "=b" (b), "=c" (c), "=d" (d)	\
+			: "0" (level), "2" (count))
 
 
 /* Return highest supported input value for cpuid instruction.  ext can


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-03-23 12:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-23 12:51 [gcc r9-9303] x86: Add __volatile__ to __cpuid and __cpuid_count 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).