From 35f7d58328231b0d1fd7b77b149012859ac130f1 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Sat, 20 Jun 2020 15:36:04 -0700 Subject: [PATCH] [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. --- compiler-rt/lib/builtins/cpu_model.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/compiler-rt/lib/builtins/cpu_model.c b/compiler-rt/lib/builtins/cpu_model.c index 86d77d816f8..c9aa42b2e67 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); -- 2.11.0