[clang] 5e92e8c - [X86] Fix the implementation of __readcr[4,8]/__writecr[4,8] to work in 64-bit mode (#122238)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 9 23:49:19 PST 2025
Author: Phoebe Wang
Date: 2025-01-10T15:49:16+08:00
New Revision: 5e92e8ca98dba21c9d8131e611f7158fe9ab3968
URL: https://github.com/llvm/llvm-project/commit/5e92e8ca98dba21c9d8131e611f7158fe9ab3968
DIFF: https://github.com/llvm/llvm-project/commit/5e92e8ca98dba21c9d8131e611f7158fe9ab3968.diff
LOG: [X86] Fix the implementation of __readcr[4,8]/__writecr[4,8] to work in 64-bit mode (#122238)
According to MSVC, __readcr4/__writecr4 return/use `unsigned __int64`,
and are supported on both x86 and x64. While __readcr8/__writecr8 are
only supported on x64. So we use __INTPTR_TYPE__ and __int64
respectively.
Following:
https://github.com/llvm/llvm-project/commit/3cec2a17de744900401c83aedb442e2acc1f23f8
Ref.:
https://learn.microsoft.com/en-us/cpp/intrinsics/readcr3?view=msvc-170
https://learn.microsoft.com/en-us/cpp/intrinsics/readcr8?view=msvc-170
Added:
Modified:
clang/lib/Headers/intrin.h
Removed:
################################################################################
diff --git a/clang/lib/Headers/intrin.h b/clang/lib/Headers/intrin.h
index e8a01d1888026c..376046aeeaf5e9 100644
--- a/clang/lib/Headers/intrin.h
+++ b/clang/lib/Headers/intrin.h
@@ -94,8 +94,8 @@ void __outwordstring(unsigned short, unsigned short *, unsigned long);
unsigned long __readcr0(void);
unsigned long __readcr2(void);
unsigned __LPTRINT_TYPE__ __readcr3(void);
-unsigned long __readcr4(void);
-unsigned long __readcr8(void);
+unsigned __LPTRINT_TYPE__ __readcr4(void);
+unsigned __int64 __readcr8(void);
unsigned int __readdr(unsigned int);
#ifdef __i386__
unsigned char __readfsbyte(unsigned long);
@@ -124,8 +124,8 @@ void __vmx_vmptrst(unsigned __int64 *);
void __wbinvd(void);
void __writecr0(unsigned int);
void __writecr3(unsigned __INTPTR_TYPE__);
-void __writecr4(unsigned int);
-void __writecr8(unsigned int);
+void __writecr4(unsigned __INTPTR_TYPE__);
+void __writecr8(unsigned __int64);
void __writedr(unsigned int, unsigned int);
void __writefsbyte(unsigned long, unsigned char);
void __writefsdword(unsigned long, unsigned long);
More information about the cfe-commits
mailing list