1 //===----------- CoreAPIsTest.cpp - Unit tests for Core ORC APIs ----------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h"
10 #include "OrcTestCommon.h"
13 using namespace llvm::orc
;
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
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.
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();
35 TargetOptions
&TO
= JTMB
.getOptions();
37 Triple
&TT
= JTMB
.getTargetTriple();
40 auto TM
= JTMB
.createTargetMachine();
43 consumeError(TM
.takeError());
45 EXPECT_NE(TM
.get(), nullptr)
46 << "JITTargetMachineBuilder should return a non-null TargetMachine "