diff --git a/llvm/include/llvm/Support/Host.h b/llvm/include/llvm/Support/Host.h --- a/llvm/include/llvm/Support/Host.h +++ b/llvm/include/llvm/Support/Host.h @@ -77,7 +77,9 @@ }; /// Returns the host CPU's vendor. - VendorSignatures getVendorSignature(); + /// MaxLeaf: if a non-nullptr pointer is specified, the EAX value will be + /// assigned to its pointee. + VendorSignatures getVendorSignature(unsigned *MaxLeaf = nullptr); } // namespace x86 #endif } diff --git a/llvm/lib/Support/Host.cpp b/llvm/lib/Support/Host.cpp --- a/llvm/lib/Support/Host.cpp +++ b/llvm/lib/Support/Host.cpp @@ -498,13 +498,15 @@ namespace detail { namespace x86 { -VendorSignatures getVendorSignature() { +VendorSignatures getVendorSignature(unsigned *MaxLeaf) { unsigned EAX = 0, EBX = 0, ECX = 0, EDX = 0; + if (MaxLeaf == nullptr) + MaxLeaf = &EAX; if (!isCpuIdSupported()) return VendorSignatures::UNKNOWN; - if (getX86CpuIDAndInfo(0, &EAX, &EBX, &ECX, &EDX) || EAX < 1) + if (getX86CpuIDAndInfo(0, MaxLeaf, &EBX, &ECX, &EDX) || *MaxLeaf < 1) return VendorSignatures::UNKNOWN; // "Genu ineI ntel" @@ -1122,7 +1124,8 @@ } StringRef sys::getHostCPUName() { - const VendorSignatures Vendor = getVendorSignature(); + unsigned MaxLeaf = 0; + const VendorSignatures Vendor = getVendorSignature(&MaxLeaf); if (Vendor == VendorSignatures::UNKNOWN) return "generic"; @@ -1131,7 +1134,6 @@ unsigned Family = 0, Model = 0; unsigned Features[(X86::CPU_FEATURE_MAX + 31) / 32] = {0}; - unsigned MaxLeaf = 0; detectX86FamilyModel(EAX, &Family, &Model); getAvailableFeatures(ECX, EDX, MaxLeaf, Features);