diff options
author | Lang Hames <lhames@gmail.com> | 2018-03-28 03:41:45 +0000 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2018-03-28 03:41:45 +0000 |
commit | a95b0df5eddbe7fa1e9f8fe0b1ff62427e1c0318 (patch) | |
tree | f51738f9e554267507fd5b0f1c0bfc2ac6ec042a /llvm/unittests/ExecutionEngine | |
parent | 816127ea17edae0c7e2d5224d86e98181a1c602c (diff) | |
download | bcm5719-llvm-a95b0df5eddbe7fa1e9f8fe0b1ff62427e1c0318.tar.gz bcm5719-llvm-a95b0df5eddbe7fa1e9f8fe0b1ff62427e1c0318.zip |
[ORC] Fix ORC on platforms without indirection support.
Previously this crashed because a nullptr (returned by
createLocalIndirectStubsManagerBuilder() on platforms without
indirection support) functor was unconditionally invoked.
Patch by Andres Freund. Thanks Andres!
llvm-svn: 328687
Diffstat (limited to 'llvm/unittests/ExecutionEngine')
3 files changed, 16 insertions, 9 deletions
diff --git a/llvm/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp b/llvm/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp index f053407a478..fe3f694f560 100644 --- a/llvm/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp +++ b/llvm/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp @@ -86,7 +86,7 @@ protected: char *OrcCAPIExecutionTest::testFuncName = nullptr; TEST_F(OrcCAPIExecutionTest, TestEagerIRCompilation) { - if (!TM) + if (!SupportsJIT) return; LLVMOrcJITStackRef JIT = @@ -112,7 +112,7 @@ TEST_F(OrcCAPIExecutionTest, TestEagerIRCompilation) { } TEST_F(OrcCAPIExecutionTest, TestLazyIRCompilation) { - if (!TM) + if (!SupportsIndirection) return; LLVMOrcJITStackRef JIT = @@ -138,7 +138,7 @@ TEST_F(OrcCAPIExecutionTest, TestLazyIRCompilation) { } TEST_F(OrcCAPIExecutionTest, TestAddObjectFile) { - if (!TM) + if (!SupportsJIT) return; auto ObjBuffer = createTestObject(); @@ -163,7 +163,7 @@ TEST_F(OrcCAPIExecutionTest, TestAddObjectFile) { } TEST_F(OrcCAPIExecutionTest, TestDirectCallbacksAPI) { - if (!TM) + if (!SupportsIndirection) return; LLVMOrcJITStackRef JIT = diff --git a/llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.h b/llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.h index 28a5f08ee43..108e2755738 100644 --- a/llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.h +++ b/llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.h @@ -17,6 +17,7 @@ #include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/JITSymbol.h" +#include "llvm/ExecutionEngine/Orc/IndirectionUtils.h" #include "llvm/IR/Function.h" #include "llvm/IR/IRBuilder.h" #include "llvm/IR/LLVMContext.h" @@ -24,6 +25,7 @@ #include "llvm/IR/TypeBuilder.h" #include "llvm/Object/ObjectFile.h" #include "llvm/Support/TargetSelect.h" +#include "llvm/Support/TargetRegistry.h" #include <memory> namespace llvm { @@ -59,15 +61,20 @@ public: // If we found a TargetMachine, check that it's one that Orc supports. const Triple& TT = TM->getTargetTriple(); - if ((TT.getArch() != Triple::x86_64 && TT.getArch() != Triple::x86) || - TT.isOSWindows()) - TM = nullptr; + // Target can JIT? + SupportsJIT = TM->getTarget().hasJIT(); + // Use ability to create callback manager to detect whether Orc + // has indirection support on this platform. This way the test + // and Orc code do not get out of sync. + SupportsIndirection = !!orc::createLocalCompileCallbackManager(TT, 0); } }; protected: LLVMContext Context; std::unique_ptr<TargetMachine> TM; + bool SupportsJIT = false; + bool SupportsIndirection = false; }; class ModuleBuilder { diff --git a/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp b/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp index 2156ae883a8..f52ee6b967e 100644 --- a/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp +++ b/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp @@ -121,7 +121,7 @@ TEST(RTDyldObjectLinkingLayerTest, TestSetProcessAllSections) { } TEST_F(RTDyldObjectLinkingLayerExecutionTest, NoDuplicateFinalization) { - if (!TM) + if (!SupportsJIT) return; SymbolStringPool SSP; @@ -206,7 +206,7 @@ TEST_F(RTDyldObjectLinkingLayerExecutionTest, NoDuplicateFinalization) { } TEST_F(RTDyldObjectLinkingLayerExecutionTest, NoPrematureAllocation) { - if (!TM) + if (!SupportsJIT) return; SymbolStringPool SSP; |