llvm-project/llvm/lib/ExecutionEngine/Orc/CMakeLists.txt

34 lines
596 B
CMake
Raw Normal View History

add_llvm_library(LLVMOrcJIT
CompileOnDemandLayer.cpp
Core.cpp
ExecutionUtils.cpp
IndirectionUtils.cpp
IRCompileLayer.cpp
IRTransformLayer.cpp
LazyReexports.cpp
Legacy.cpp
Layer.cpp
LLJIT.cpp
NullResolver.cpp
ObjectTransformLayer.cpp
OrcABISupport.cpp
OrcCBindings.cpp
OrcError.cpp
OrcMCJITReplacement.cpp
RPCUtils.cpp
RTDyldObjectLinkingLayer.cpp
[ORC] Add ThreadSafeModule and ThreadSafeContext wrappers to support concurrent compilation of IR in the JIT. ThreadSafeContext is a pair of an LLVMContext and a mutex that can be used to lock that context when it needs to be accessed from multiple threads. ThreadSafeModule is a pair of a unique_ptr<Module> and a shared_ptr<ThreadSafeContext>. This allows the lifetime of a ThreadSafeContext to be managed automatically in terms of the ThreadSafeModules that refer to it: Once all modules using a ThreadSafeContext are destructed, and providing the client has not held on to a copy of shared context pointer, the context will be automatically destructed. This scheme is necessary due to the following constraits: (1) We need multiple contexts for multithreaded compilation (at least one per compile thread plus one to store any IR not currently being compiled, though one context per module is simpler). (2) We need to free contexts that are no longer being used so that the JIT does not leak memory over time. (3) Module lifetimes are not predictable (modules are compiled as needed depending on the flow of JIT'd code) so there is no single point where contexts could be reclaimed. JIT clients not using concurrency can safely use one ThreadSafeContext for all ThreadSafeModules. JIT clients who want to be able to compile concurrently should use a different ThreadSafeContext for each module, or call setCloneToNewContextOnEmit on their top-level IRLayer. The former reduces compile latency (since no clone step is needed) at the cost of additional memory overhead for uncompiled modules (as every uncompiled module will duplicate the LLVM types, constants and metadata that have been shared). llvm-svn: 343055
2018-09-26 09:24:12 +08:00
ThreadSafeModule.cpp
ADDITIONAL_HEADER_DIRS
${LLVM_MAIN_INCLUDE_DIR}/llvm/ExecutionEngine/Orc
DEPENDS
intrinsics_gen
)
target_link_libraries(LLVMOrcJIT
PRIVATE
LLVMBitReader
LLVMBitWriter
)