1 //===----------- CoreAPIsTest.cpp - Unit tests for Core ORC APIs ----------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h" 11 #include "OrcTestCommon.h" 12 13 using namespace llvm; 14 using namespace llvm::orc; 15 16 namespace { 17 18 TEST(ExecutionUtilsTest, JITTargetMachineBuilder) { 19 // Tests basic API usage. 20 // Bails out on error, as it is valid to run this test without any targets 21 // built. 22 23 // Make sure LLVM has been initialized. 24 OrcNativeTarget::initialize(); 25 26 auto JTMB = cantFail(JITTargetMachineBuilder::detectHost()); 27 28 // Test API by performing a bunch of no-ops. 29 JTMB.setCPU(""); 30 JTMB.setRelocationModel(None); 31 JTMB.setCodeModel(None); 32 JTMB.setCodeGenOptLevel(CodeGenOpt::None); 33 JTMB.addFeatures(std::vector<std::string>()); 34 SubtargetFeatures &STF = JTMB.getFeatures(); 35 (void)STF; 36 TargetOptions &TO = JTMB.getOptions(); 37 (void)TO; 38 Triple &TT = JTMB.getTargetTriple(); 39 (void)TT; 40 41 auto TM = JTMB.createTargetMachine(); 42 43 if (!TM) 44 consumeError(TM.takeError()); 45 else { 46 EXPECT_NE(TM.get(), nullptr) 47 << "JITTargetMachineBuilder should return a non-null TargetMachine " 48 "on success"; 49 } 50 } 51 52 } // namespace 53