From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1039) id 2A0DD3854805; Tue, 23 Mar 2021 12:52:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2A0DD3854805 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: H.J. Lu To: gcc-cvs@gcc.gnu.org Subject: [gcc r8-10816] x86: Add __volatile__ to __cpuid and __cpuid_count X-Act-Checkin: gcc X-Git-Author: H.J. Lu X-Git-Refname: refs/heads/releases/gcc-8 X-Git-Oldrev: 1158bc2e575822b6447c823580702a126836830a X-Git-Newrev: 3553e057df3a7fb2524339b1681fe3153ae7d568 Message-Id: <20210323125259.2A0DD3854805@sourceware.org> Date: Tue, 23 Mar 2021 12:52:59 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Mar 2021 12:52:59 -0000 https://gcc.gnu.org/g:3553e057df3a7fb2524339b1681fe3153ae7d568 commit r8-10816-g3553e057df3a7fb2524339b1681fe3153ae7d568 Author: H.J. Lu 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 . 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 962e7532a85..19c705f847c 100644 --- a/gcc/config/i386/cpuid.h +++ b/gcc/config/i386/cpuid.h @@ -182,28 +182,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