From 0c1c5b0aaac80ca233523379617df93bbc0e2014 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Fri, 16 Aug 2013 22:42:42 +0000 Subject: [PATCH] Actually, use GNU inline asm for cpuid with clang Clang doesn't support the MSVC __cpuid intrinsic yet, and fixing that is blocked on some fairly complicated issues. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188584 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/Host.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/Support/Host.cpp b/lib/Support/Host.cpp index 9360cb979f7..ad0ac93b6bd 100644 --- a/lib/Support/Host.cpp +++ b/lib/Support/Host.cpp @@ -54,16 +54,7 @@ using namespace llvm; /// specified arguments. If we can't run cpuid on the host, return true. static bool GetX86CpuIDAndInfo(unsigned value, unsigned *rEAX, unsigned *rEBX, unsigned *rECX, unsigned *rEDX) { -#if defined(_MSC_VER) - // The MSVC intrinsic is portable across x86 and x64. - int registers[4]; - __cpuid(registers, value); - *rEAX = registers[0]; - *rEBX = registers[1]; - *rECX = registers[2]; - *rEDX = registers[3]; - return false; -#elif defined(__GNUC__) +#if defined(__GNUC__) || defined(__clang__) #if defined(__x86_64__) || defined(_M_AMD64) || defined (_M_X64) // gcc doesn't know cpuid would clobber ebx/rbx. Preseve it manually. asm ("movq\t%%rbx, %%rsi\n\t" @@ -90,6 +81,15 @@ static bool GetX86CpuIDAndInfo(unsigned value, unsigned *rEAX, unsigned *rEBX, #else return true; #endif +#elif defined(_MSC_VER) + // The MSVC intrinsic is portable across x86 and x64. + int registers[4]; + __cpuid(registers, value); + *rEAX = registers[0]; + *rEBX = registers[1]; + *rECX = registers[2]; + *rEDX = registers[3]; + return false; #else return true; #endif