1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00
llvm-mirror/examples/Kaleidoscope
Lang Hames a6587cc70d [ORC] Change the locking scheme for ThreadSafeModule.
ThreadSafeModule/ThreadSafeContext are used to manage lifetimes and locking
for LLVMContexts in ORCv2. Prior to this patch contexts were locked as soon
as an associated Module was emitted (to be compiled and linked), and were not
unlocked until the emit call returned. This could lead to deadlocks if
interdependent modules that shared contexts were compiled on different threads:
when, during emission of the first module, the dependence was discovered the
second module (which would provide the required symbol) could not be emitted as
the thread emitting the first module still held the lock.

This patch eliminates this possibility by moving to a finer-grained locking
scheme. Each client holds the module lock only while they are actively operating
on it. To make this finer grained locking simpler/safer to implement this patch
removes the explicit lock method, 'getContextLock', from ThreadSafeModule and
replaces it with a new method, 'withModuleDo', that implicitly locks the context,
calls a user-supplied function object to operate on the Module, then implicitly
unlocks the context before returning the result.

ThreadSafeModule TSM = getModule(...);
size_t NumFunctions = TSM.withModuleDo(
    [](Module &M) { // <- context locked before entry to lambda.
      return M.size();
    });

Existing ORCv2 layers that operate on ThreadSafeModules are updated to use the
new method.

This method is used to introduce Module locking into each of the existing
layers.

llvm-svn: 367686
2019-08-02 15:21:37 +00:00
..
BuildingAJIT [ORC] Change the locking scheme for ThreadSafeModule. 2019-08-02 15:21:37 +00:00
Chapter2 Fix some warnings on MSVC 2019-01-27 18:41:40 +00:00
Chapter3 Use print() instead of dump() in code 2017-01-28 02:47:46 +00:00
Chapter4 s/LLVM_ON_WIN32/_WIN32/, llvm 2018-04-29 00:45:03 +00:00
Chapter5 s/LLVM_ON_WIN32/_WIN32/, llvm 2018-04-29 00:45:03 +00:00
Chapter6 s/LLVM_ON_WIN32/_WIN32/, llvm 2018-04-29 00:45:03 +00:00
Chapter7 s/LLVM_ON_WIN32/_WIN32/, llvm 2018-04-29 00:45:03 +00:00
Chapter8 Unbreak kaleidoscope example. 2018-05-21 22:09:45 +00:00
Chapter9 Fix build break from r347239 2018-11-19 18:51:11 +00:00
include [ORC] Add deprecation warnings to ORCv1 layers and utilities. 2019-07-17 16:40:52 +00:00
MCJIT Python compat - print statement 2019-01-03 14:11:33 +00:00
CMakeLists.txt PR35705: Fix Chapter 9 example code for API changes to DIBuilder 2017-12-20 19:36:54 +00:00