[clang] [X86] Fix the implementation of __readcr[4, 8]/__writecr[4, 8] to work in 64-bit mode (PR #122238)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 9 01:31:38 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Phoebe Wang (phoebewang)
<details>
<summary>Changes</summary>
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
---
Full diff: https://github.com/llvm/llvm-project/pull/122238.diff
1 Files Affected:
- (modified) clang/lib/Headers/intrin.h (+4-4)
``````````diff
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);
``````````
</details>
https://github.com/llvm/llvm-project/pull/122238
More information about the cfe-commits
mailing list