From 20b5abe23b33b924a9f1a7ad62f3a9d9e118ebf5 Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Wed, 26 Sep 2018 12:15:23 +0000 Subject: Revert r343058 "[ORC] Add support for multithreaded compiles to LLJIT and LLLazyJIT." This doesn't work well in builds configured with LLVM_ENABLE_THREADS=OFF, causing the following assert when running ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll: lib/ExecutionEngine/Orc/Core.cpp:1748: Expected llvm::orc::lookup(const llvm::orc::JITDylibList &, llvm::orc::SymbolStringPtr): Assertion `ResultMap->size() == 1 && "Unexpected number of results"' failed. > LLJIT and LLLazyJIT can now be constructed with an optional NumCompileThreads > arguments. If this is non-zero then a thread-pool will be created with the > given number of threads, and compile tasks will be dispatched to the thread > pool. > > To enable testing of this feature, two new flags are added to lli: > > (1) -compile-threads=N (N = 0 by default) controls the number of compile threads > to use. > > (2) -thread-entry can be used to execute code on additional threads. For each > -thread-entry argument supplied (multiple are allowed) a new thread will be > created and the given symbol called. These additional thread entry points are > called after static constructors are run, but before main. llvm-svn: 343099 --- llvm/tools/lli/lli.cpp | 54 ++++++-------------------------------------------- 1 file changed, 6 insertions(+), 48 deletions(-) (limited to 'llvm/tools/lli/lli.cpp') diff --git a/llvm/tools/lli/lli.cpp b/llvm/tools/lli/lli.cpp index 49d5db13326..2312d770348 100644 --- a/llvm/tools/lli/lli.cpp +++ b/llvm/tools/lli/lli.cpp @@ -97,17 +97,6 @@ namespace { "orc-lazy", "Orc-based lazy JIT."))); - cl::opt - LazyJITCompileThreads("compile-threads", - cl::desc("Choose the number of compile threads " - "(jit-kind=orc-lazy only)"), - cl::init(0)); - - cl::list - ThreadEntryPoints("thread-entry", - cl::desc("calls the given entry-point on a new thread " - "(jit-kind=orc-lazy only)")); - // The MCJIT supports building for a target address space separate from // the JIT compilation process. Use a forked process and a copying // memory manager with IPC to execute using this functionality. @@ -374,19 +363,6 @@ int main(int argc, char **argv, char * const *envp) { if (UseJITKind == JITKind::OrcLazy) return runOrcLazyJIT(argv[0]); - else { - // Make sure nobody used an orc-lazy specific option accidentally. - - if (LazyJITCompileThreads != 0) { - errs() << "-compile-threads requires -jit-kind=orc-lazy\n"; - exit(1); - } - - if (!ThreadEntryPoints.empty()) { - errs() << "-thread-entry requires -jit-kind=orc-lazy\n"; - exit(1); - } - } LLVMContext Context; @@ -769,11 +745,11 @@ int runOrcLazyJIT(const char *ProgName) { reportError(Err, ProgName); const auto &TT = MainModule.getModule()->getTargetTriple(); - orc::JITTargetMachineBuilder JTMB = + orc::JITTargetMachineBuilder TMD = TT.empty() ? ExitOnErr(orc::JITTargetMachineBuilder::detectHost()) : orc::JITTargetMachineBuilder(Triple(TT)); - JTMB.setArch(MArch) + TMD.setArch(MArch) .setCPU(getCPUStr()) .addFeatures(getFeatureList()) .setRelocationModel(RelocModel.getNumOccurrences() @@ -782,13 +758,9 @@ int runOrcLazyJIT(const char *ProgName) { .setCodeModel(CMModel.getNumOccurrences() ? Optional(CMModel) : None); - DataLayout DL(""); - { - // Create a throwaway TargetMachine to get the data layout. - auto TM = ExitOnErr(JTMB.createTargetMachine()); - DL = TM->createDataLayout(); - } - auto J = ExitOnErr(orc::LLLazyJIT::Create(std::move(JTMB), DL, LazyJITCompileThreads)); + auto TM = ExitOnErr(TMD.createTargetMachine()); + auto DL = TM->createDataLayout(); + auto J = ExitOnErr(orc::LLLazyJIT::Create(std::move(TM), DL)); auto Dump = createDebugDumper(); @@ -835,16 +807,6 @@ int runOrcLazyJIT(const char *ProgName) { // Run any static constructors. ExitOnErr(J->runConstructors()); - // Run any -thread-entry points. - std::vector AltEntryThreads; - for (auto &ThreadEntryPoint : ThreadEntryPoints) { - auto EntryPointSym = ExitOnErr(J->lookup(ThreadEntryPoint)); - typedef void (*EntryPointPtr)(); - auto EntryPoint = - reinterpret_cast(static_cast(EntryPointSym.getAddress())); - AltEntryThreads.push_back(std::thread([EntryPoint]() { EntryPoint(); })); - } - // Run main. auto MainSym = ExitOnErr(J->lookup("main")); typedef int (*MainFnPtr)(int, const char *[]); @@ -855,12 +817,8 @@ int runOrcLazyJIT(const char *ProgName) { reinterpret_cast(static_cast(MainSym.getAddress())); auto Result = Main(ArgV.size(), (const char **)ArgV.data()); - // Wait for -entry-point threads. - for (auto &AltEntryThread : AltEntryThreads) - AltEntryThread.join(); - - // Run destructors. ExitOnErr(J->runDestructors()); + CXXRuntimeOverrides.runDestructors(); return Result; -- cgit v1.2.3