-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[X86] Fix the implementation of __readcr[4,8]/__writecr[4,8] to work in 64-bit mode #122238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…in 64-bit mode 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 llvm@3cec2a1 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
@llvm/pr-subscribers-backend-x86 Author: Phoebe Wang (phoebewang) ChangesAccording to MSVC, __readcr4/__writecr4 return/use Following: 3cec2a1 Ref.: Full diff: https://github.com/llvm/llvm-project/pull/122238.diff 1 Files Affected:
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);
|
@llvm/pr-subscribers-clang Author: Phoebe Wang (phoebewang) ChangesAccording to MSVC, __readcr4/__writecr4 return/use Following: 3cec2a1 Ref.: Full diff: https://github.com/llvm/llvm-project/pull/122238.diff 1 Files Affected:
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);
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I see we don't actually implement these intrinsics at this point, but fixing them to avoid redeclaration errors is reasonable.
…in 64-bit mode (llvm#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: llvm@3cec2a1 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
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: 3cec2a1
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