[compiler-rt] 35f7d58 - [X86] Set the cpu_vendor in __cpu_indicator_init to VENDOR_OTHER if cpuid isn't supported on the CPU.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 20 15:36:22 PDT 2020
Author: Craig Topper
Date: 2020-06-20T15:36:04-07:00
New Revision: 35f7d58328231b0d1fd7b77b149012859ac130f1
URL: https://github.com/llvm/llvm-project/commit/35f7d58328231b0d1fd7b77b149012859ac130f1
DIFF: https://github.com/llvm/llvm-project/commit/35f7d58328231b0d1fd7b77b149012859ac130f1.diff
LOG: [X86] Set the cpu_vendor in __cpu_indicator_init to VENDOR_OTHER if cpuid isn't supported on the CPU.
We need to set the cpu_vendor to a non-zero value to indicate
that we already called __cpu_indicator_init once.
This should only happen on a 386 or 486 CPU.
Added:
Modified:
compiler-rt/lib/builtins/cpu_model.c
Removed:
################################################################################
diff --git a/compiler-rt/lib/builtins/cpu_model.c b/compiler-rt/lib/builtins/cpu_model.c
index 86d77d816f81..c9aa42b2e673 100644
--- a/compiler-rt/lib/builtins/cpu_model.c
+++ b/compiler-rt/lib/builtins/cpu_model.c
@@ -655,14 +655,12 @@ int CONSTRUCTOR_ATTRIBUTE __cpu_indicator_init(void) {
if (__cpu_model.__cpu_vendor)
return 0;
- if (!isCpuIdSupported())
- return -1;
-
- // Assume cpuid insn present. Run in level 0 to get vendor id.
- if (getX86CpuIDAndInfo(0, &MaxLeaf, &Vendor, &ECX, &EDX) || MaxLeaf < 1) {
+ if (!isCpuIdSupported() ||
+ getX86CpuIDAndInfo(0, &MaxLeaf, &Vendor, &ECX, &EDX) || MaxLeaf < 1) {
__cpu_model.__cpu_vendor = VENDOR_OTHER;
return -1;
}
+
getX86CpuIDAndInfo(1, &EAX, &EBX, &ECX, &EDX);
detectX86FamilyModel(EAX, &Family, &Model);
More information about the llvm-commits
mailing list