Fix r332592 : X86 tests should use the X86 target, not the native targets.

llvm-svn: 332594
This commit is contained in:
Clement Courbet 2018-05-17 11:31:24 +00:00
parent a2a9cfab83
commit 0994ec2f21
1 changed files with 14 additions and 5 deletions

View File

@ -4,7 +4,6 @@
#include <memory> #include <memory>
#include "X86InstrInfo.h" #include "X86InstrInfo.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/TargetRegistry.h" #include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/TargetSelect.h" #include "llvm/Support/TargetSelect.h"
#include "gmock/gmock.h" #include "gmock/gmock.h"
@ -16,17 +15,27 @@ namespace {
class RegisterAliasingTest : public ::testing::Test { class RegisterAliasingTest : public ::testing::Test {
protected: protected:
RegisterAliasingTest() { RegisterAliasingTest() {
const std::string TT = llvm::sys::getProcessTriple(); const std::string TT = "x86_64-unknown-linux";
std::string error; std::string error;
const llvm::Target *const TheTarget = const llvm::Target *const TheTarget =
llvm::TargetRegistry::lookupTarget(TT, error); llvm::TargetRegistry::lookupTarget(TT, error);
assert(TheTarget); if (!TheTarget) {
llvm::errs() << error << "\n";
return;
}
MCRegInfo.reset(TheTarget->createMCRegInfo(TT)); MCRegInfo.reset(TheTarget->createMCRegInfo(TT));
} }
static void SetUpTestCase() { llvm::InitializeNativeTarget(); } static void SetUpTestCase() {
LLVMInitializeX86TargetInfo();
LLVMInitializeX86Target();
LLVMInitializeX86TargetMC();
}
const llvm::MCRegisterInfo &getMCRegInfo() { return *MCRegInfo; } const llvm::MCRegisterInfo &getMCRegInfo() {
assert(MCRegInfo);
return *MCRegInfo;
}
private: private:
std::unique_ptr<const llvm::MCRegisterInfo> MCRegInfo; std::unique_ptr<const llvm::MCRegisterInfo> MCRegInfo;