summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ExecutionEngine/Orc/JITTargetMachineBuilderTest.cpp
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2018-09-30 19:12:23 +0000
committerLang Hames <lhames@gmail.com>2018-09-30 19:12:23 +0000
commitd435ce4343267e147289aa8d8264d308c6639647 (patch)
tree6172459f46f6491e0f081233b485dbbf9745b6a1 /llvm/unittests/ExecutionEngine/Orc/JITTargetMachineBuilderTest.cpp
parent0f8f0d6d1df8d17765ea5b34b117d85142b2bf24 (diff)
downloadbcm5719-llvm-d435ce4343267e147289aa8d8264d308c6639647.tar.gz
bcm5719-llvm-d435ce4343267e147289aa8d8264d308c6639647.zip
[ORC] Extract and tidy up JITTargetMachineBuilder, add unit test.
(1) Adds comments for the API. (2) Removes the setArch method: This is redundant: the setArchStr method on the triple should be used instead. (3) Turns EmulatedTLS on by default. This matches EngineBuilder's behavior. llvm-svn: 343423
Diffstat (limited to 'llvm/unittests/ExecutionEngine/Orc/JITTargetMachineBuilderTest.cpp')
-rw-r--r--llvm/unittests/ExecutionEngine/Orc/JITTargetMachineBuilderTest.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/llvm/unittests/ExecutionEngine/Orc/JITTargetMachineBuilderTest.cpp b/llvm/unittests/ExecutionEngine/Orc/JITTargetMachineBuilderTest.cpp
new file mode 100644
index 00000000000..f978a90efb3
--- /dev/null
+++ b/llvm/unittests/ExecutionEngine/Orc/JITTargetMachineBuilderTest.cpp
@@ -0,0 +1,52 @@
+//===----------- CoreAPIsTest.cpp - Unit tests for Core ORC APIs ----------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h"
+#include "OrcTestCommon.h"
+
+using namespace llvm;
+using namespace llvm::orc;
+
+namespace {
+
+TEST(ExecutionUtilsTest, JITTargetMachineBuilder) {
+ // Tests basic API usage.
+ // Bails out on error, as it is valid to run this test without any targets
+ // built.
+
+ // Make sure LLVM has been initialized.
+ OrcNativeTarget::initialize();
+
+ auto JTMB = cantFail(JITTargetMachineBuilder::detectHost());
+
+ // Test API by performing a bunch of no-ops.
+ JTMB.setCPU("");
+ JTMB.setRelocationModel(None);
+ JTMB.setCodeModel(None);
+ JTMB.setCodeGenOptLevel(CodeGenOpt::None);
+ JTMB.addFeatures(std::vector<std::string>());
+ SubtargetFeatures &STF = JTMB.getFeatures();
+ (void)STF;
+ TargetOptions &TO = JTMB.getOptions();
+ (void)TO;
+ Triple &TT = JTMB.getTargetTriple();
+ (void)TT;
+
+ auto TM = JTMB.createTargetMachine();
+
+ if (!TM)
+ consumeError(TM.takeError());
+ else {
+ EXPECT_NE(TM.get(), nullptr)
+ << "JITTargetMachineBuilder should return a non-null TargetMachine "
+ "on success";
+ }
+}
+
+} // namespace
OpenPOWER on IntegriCloud