[llvm] [cmake] Add possibility to use ChooseMSVCCRT.cmake when include LLVM library
[llvm-core.git] / unittests / ExecutionEngine / Orc / JITTargetMachineBuilderTest.cpp
blob1f3626e8af13168b3bcfe43eabbcde9ea364fab7
1 //===----------- CoreAPIsTest.cpp - Unit tests for Core ORC APIs ----------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h"
10 #include "OrcTestCommon.h"
12 using namespace llvm;
13 using namespace llvm::orc;
15 namespace {
17 TEST(ExecutionUtilsTest, JITTargetMachineBuilder) {
18 // Tests basic API usage.
19 // Bails out on error, as it is valid to run this test without any targets
20 // built.
22 // Make sure LLVM has been initialized.
23 OrcNativeTarget::initialize();
25 auto JTMB = cantFail(JITTargetMachineBuilder::detectHost());
27 // Test API by performing a bunch of no-ops.
28 JTMB.setCPU("");
29 JTMB.setRelocationModel(None);
30 JTMB.setCodeModel(None);
31 JTMB.setCodeGenOptLevel(CodeGenOpt::None);
32 JTMB.addFeatures(std::vector<std::string>());
33 SubtargetFeatures &STF = JTMB.getFeatures();
34 (void)STF;
35 TargetOptions &TO = JTMB.getOptions();
36 (void)TO;
37 Triple &TT = JTMB.getTargetTriple();
38 (void)TT;
40 auto TM = JTMB.createTargetMachine();
42 if (!TM)
43 consumeError(TM.takeError());
44 else {
45 EXPECT_NE(TM.get(), nullptr)
46 << "JITTargetMachineBuilder should return a non-null TargetMachine "
47 "on success";
51 } // namespace