Index: tools/llvm-exegesis/lib/LlvmState.h =================================================================== --- tools/llvm-exegesis/lib/LlvmState.h +++ tools/llvm-exegesis/lib/LlvmState.h @@ -32,6 +32,9 @@ public: LLVMState(); + LLVMState(const std::string &Triple, + const std::string &CpuName); // For tests. + llvm::StringRef getTriple() const { return TheTriple; } llvm::StringRef getCpuName() const { return CpuName; } llvm::StringRef getFeatures() const { return Features; } Index: tools/llvm-exegesis/lib/LlvmState.cpp =================================================================== --- tools/llvm-exegesis/lib/LlvmState.cpp +++ tools/llvm-exegesis/lib/LlvmState.cpp @@ -20,9 +20,8 @@ namespace exegesis { -LLVMState::LLVMState() - : TheTriple(llvm::sys::getProcessTriple()), - CpuName(llvm::sys::getHostCPUName().str()) { +LLVMState::LLVMState(const std::string &Triple, const std::string &CpuName) + : TheTriple(Triple), CpuName(CpuName) { std::string Error; TheTarget = llvm::TargetRegistry::lookupTarget(TheTriple, Error); assert(TheTarget && "unknown target for host"); @@ -33,6 +32,10 @@ AsmInfo.reset(TheTarget->createMCAsmInfo(*RegInfo, TheTriple)); } +LLVMState::LLVMState() + : LLVMState(llvm::sys::getProcessTriple(), + llvm::sys::getHostCPUName().str()) {} + std::unique_ptr LLVMState::createTargetMachine() const { const llvm::TargetOptions Options; Index: unittests/tools/llvm-exegesis/X86/SnippetGeneratorTest.cpp =================================================================== --- unittests/tools/llvm-exegesis/X86/SnippetGeneratorTest.cpp +++ unittests/tools/llvm-exegesis/X86/SnippetGeneratorTest.cpp @@ -23,7 +23,8 @@ class X86SnippetGeneratorTest : public ::testing::Test { protected: X86SnippetGeneratorTest() - : MCInstrInfo(State.getInstrInfo()), MCRegisterInfo(State.getRegInfo()) {} + : State("x86_64-unknown-linux", "haswell"), + MCInstrInfo(State.getInstrInfo()), MCRegisterInfo(State.getRegInfo()) {} static void SetUpTestCase() { LLVMInitializeX86TargetInfo();