public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r10-9523] x86: Add __volatile__ to __cpuid and __cpuid_count
@ 2021-03-23 12:40 H.J. Lu
0 siblings, 0 replies; only message in thread
From: H.J. Lu @ 2021-03-23 12:40 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:6ee221e98e6a9363fe962b1babbe92eba286fa18
commit r10-9523-g6ee221e98e6a9363fe962b1babbe92eba286fa18
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 34a7956d36a..ce4b38c6417 100644
--- a/gcc/config/i386/cpuid.h
+++ b/gcc/config/i386/cpuid.h
@@ -193,28 +193,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:40 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:40 [gcc r10-9523] 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).