[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
diff --git a/llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.h b/llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.h
index 28a5f08..108e275 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 @@
// 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 {