[llvm] r328687 - [ORC] Fix ORC on platforms without indirection support.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 27 20:41:45 PDT 2018
Author: lhames
Date: Tue Mar 27 20:41:45 2018
New Revision: 328687
URL: http://llvm.org/viewvc/llvm-project?rev=328687&view=rev
Log:
[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!
Modified:
llvm/trunk/lib/ExecutionEngine/Orc/IndirectionUtils.cpp
llvm/trunk/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp
llvm/trunk/unittests/ExecutionEngine/Orc/OrcTestCommon.h
llvm/trunk/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp
Modified: llvm/trunk/lib/ExecutionEngine/Orc/IndirectionUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Orc/IndirectionUtils.cpp?rev=328687&r1=328686&r2=328687&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/Orc/IndirectionUtils.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/Orc/IndirectionUtils.cpp Tue Mar 27 20:41:45 2018
@@ -54,7 +54,11 @@ createLocalCompileCallbackManager(const
std::function<std::unique_ptr<IndirectStubsManager>()>
createLocalIndirectStubsManagerBuilder(const Triple &T) {
switch (T.getArch()) {
- default: return nullptr;
+ default:
+ return [](){
+ return llvm::make_unique<
+ orc::LocalIndirectStubsManager<orc::OrcGenericABI>>();
+ };
case Triple::aarch64:
return [](){
Modified: llvm/trunk/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp?rev=328687&r1=328686&r2=328687&view=diff
==============================================================================
--- llvm/trunk/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp (original)
+++ llvm/trunk/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp Tue Mar 27 20:41:45 2018
@@ -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, TestEagerIR
}
TEST_F(OrcCAPIExecutionTest, TestLazyIRCompilation) {
- if (!TM)
+ if (!SupportsIndirection)
return;
LLVMOrcJITStackRef JIT =
@@ -138,7 +138,7 @@ TEST_F(OrcCAPIExecutionTest, TestLazyIRC
}
TEST_F(OrcCAPIExecutionTest, TestAddObjectFile) {
- if (!TM)
+ if (!SupportsJIT)
return;
auto ObjBuffer = createTestObject();
@@ -163,7 +163,7 @@ TEST_F(OrcCAPIExecutionTest, TestAddObje
}
TEST_F(OrcCAPIExecutionTest, TestDirectCallbacksAPI) {
- if (!TM)
+ if (!SupportsIndirection)
return;
LLVMOrcJITStackRef JIT =
Modified: llvm/trunk/unittests/ExecutionEngine/Orc/OrcTestCommon.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/Orc/OrcTestCommon.h?rev=328687&r1=328686&r2=328687&view=diff
==============================================================================
--- llvm/trunk/unittests/ExecutionEngine/Orc/OrcTestCommon.h (original)
+++ llvm/trunk/unittests/ExecutionEngine/Orc/OrcTestCommon.h Tue Mar 27 20:41:45 2018
@@ -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 {
Modified: llvm/trunk/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp?rev=328687&r1=328686&r2=328687&view=diff
==============================================================================
--- llvm/trunk/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp (original)
+++ llvm/trunk/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp Tue Mar 27 20:41:45 2018
@@ -121,7 +121,7 @@ TEST(RTDyldObjectLinkingLayerTest, TestS
}
TEST_F(RTDyldObjectLinkingLayerExecutionTest, NoDuplicateFinalization) {
- if (!TM)
+ if (!SupportsJIT)
return;
SymbolStringPool SSP;
@@ -206,7 +206,7 @@ TEST_F(RTDyldObjectLinkingLayerExecution
}
TEST_F(RTDyldObjectLinkingLayerExecutionTest, NoPrematureAllocation) {
- if (!TM)
+ if (!SupportsJIT)
return;
SymbolStringPool SSP;
More information about the llvm-commits
mailing list