aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/Host.cpp
diff options
context:
space:
mode:
authorAlina Sbirlea <asbirlea@google.com>2016-07-20 18:54:26 +0000
committerAlina Sbirlea <asbirlea@google.com>2016-07-20 18:54:26 +0000
commitb86aa17b06603c59dd291920156b2bb895637506 (patch)
treec1ddbce7eb59b5417556f3273744e1e1b292c9dc /llvm/lib/Support/Host.cpp
parent1d175fbc46c3b5311fb432d222eef96269af0a43 (diff)
downloadllvm-b86aa17b06603c59dd291920156b2bb895637506.zip
llvm-b86aa17b06603c59dd291920156b2bb895637506.tar.gz
llvm-b86aa17b06603c59dd291920156b2bb895637506.tar.bz2
Properly ifdef the use of cpuid.
llvm-svn: 276156
Diffstat (limited to 'llvm/lib/Support/Host.cpp')
-rw-r--r--llvm/lib/Support/Host.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/Support/Host.cpp b/llvm/lib/Support/Host.cpp
index a02a4ab..689e050 100644
--- a/llvm/lib/Support/Host.cpp
+++ b/llvm/lib/Support/Host.cpp
@@ -22,7 +22,6 @@
#include "llvm/Support/raw_ostream.h"
#include <string.h>
#include <assert.h>
-#include <cpuid.h>
// Include the platform-specific parts of this class.
#ifdef LLVM_ON_UNIX
@@ -74,6 +73,10 @@ static ssize_t LLVM_ATTRIBUTE_UNUSED readCpuInfo(void *Buf, size_t Size) {
#if defined(__i386__) || defined(_M_IX86) || \
defined(__x86_64__) || defined(_M_X64)
+#if defined(__GNUC__) || defined(__clang__)
+#include <cpuid.h>
+#endif
+
enum VendorSignatures {
SIG_INTEL = 0x756e6547 /* Genu */,
SIG_AMD = 0x68747541 /* Auth */
@@ -741,11 +744,13 @@ StringRef sys::getHostCPUName() {
unsigned EAX = 0, EBX = 0, ECX = 0, EDX = 0;
unsigned MaxLeaf, Vendor;
+#if defined(__GNUC__) || defined(__clang__)
//FIXME: include cpuid.h from clang or copy __get_cpuid_max here
// and simplify it to not invoke __cpuid (like cpu_model.c in
// compiler-rt/lib/builtins/cpu_model.c?
if(!__get_cpuid_max(0, &Vendor))
return "generic";
+#endif
if (getX86CpuIDAndInfo(0, &MaxLeaf, &Vendor, &ECX, &EDX))
return "generic";
if (getX86CpuIDAndInfo(0x1, &EAX, &EBX, &ECX, &EDX))