Skip to content

Commit

Permalink
Refactor getHostCPUName to allow testing on non-native hardware.
Browse files Browse the repository at this point in the history
This refactors getHostCPUName so that for the architectures that get the
host cpu info on linux from /proc/cpuinfo, the /proc/cpuinfo parsing
logic is present in the build, even if it wasn't built on a linux system
for that architecture.

Since the code is present in the build, we can then test that code also
on other systems, i.e. we don't need to have buildbots setup for all
architectures on linux to be able to test this. Instead, developers will
test this as part of the regression test run.

As an example, a few unit tests are added to test getHostCPUName for ARM
running linux. A unit test is preferred over a lit-based test, since the
expectation is that in the future, the functionality here will grow over
what can be tested with "llc -mcpu=native".

This is a preparation step to enable implementing the range of
improvements discussed on PR30516, such as adding AArch64 support,
support for big.LITTLE systems, reducing code duplication.

Differential Revision: https://reviews.llvm.org/D31236

llvm-svn: 299060
  • Loading branch information
kbeyls committed Mar 30, 2017
1 parent eafcbe2 commit 9e46396
Show file tree
Hide file tree
Showing 3 changed files with 256 additions and 214 deletions.
8 changes: 8 additions & 0 deletions llvm/include/llvm/Support/Host.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#define LLVM_SUPPORT_HOST_H

#include "llvm/ADT/StringMap.h"
#include "llvm/Support/MemoryBuffer.h"

#if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__)
#include <endian.h>
Expand Down Expand Up @@ -75,6 +76,13 @@ constexpr bool IsBigEndianHost = false;
/// from thread::hardware_concurrency(), which includes hyperthreads).
/// Returns -1 if unknown for the current host system.
int getHostNumPhysicalCores();

/// helper functions to extract HostCPUName from /proc/cpuinfo on linux.
namespace LinuxReadCpuInfo {
StringRef getHostCPUName_powerpc(const StringRef &ProcCpuinfoContent);
StringRef getHostCPUName_arm(const StringRef &ProcCpuinfoContent);
StringRef getHostCPUName_s390x(const StringRef &ProcCpuinfoContent);
}
}
}

Expand Down

0 comments on commit 9e46396

Please sign in to comment.