@@ -2170,62 +2170,25 @@ compiler, consider compiling LLVM and LLVM-GCC in single-threaded mode, and
2170
2170
using the resultant compiler to build a copy of LLVM with multithreading
2171
2171
support.
2172
2172
2173
- .. _startmultithreaded :
2174
-
2175
- Entering and Exiting Multithreaded Mode
2176
- ---------------------------------------
2177
-
2178
- In order to properly protect its internal data structures while avoiding
2179
- excessive locking overhead in the single-threaded case, the LLVM must intialize
2180
- certain data structures necessary to provide guards around its internals. To do
2181
- so, the client program must invoke ``llvm_start_multithreaded() `` before making
2182
- any concurrent LLVM API calls. To subsequently tear down these structures, use
2183
- the ``llvm_stop_multithreaded() `` call. You can also use the
2184
- ``llvm_is_multithreaded() `` call to check the status of multithreaded mode.
2185
-
2186
- Note that both of these calls must be made *in isolation *. That is to say that
2187
- no other LLVM API calls may be executing at any time during the execution of
2188
- ``llvm_start_multithreaded() `` or ``llvm_stop_multithreaded ``. It is the
2189
- client's responsibility to enforce this isolation.
2190
-
2191
- The return value of ``llvm_start_multithreaded() `` indicates the success or
2192
- failure of the initialization. Failure typically indicates that your copy of
2193
- LLVM was built without multithreading support, typically because GCC atomic
2194
- intrinsics were not found in your system compiler. In this case, the LLVM API
2195
- will not be safe for concurrent calls. However, it *will * be safe for hosting
2196
- threaded applications in the JIT, though :ref: `care must be taken
2197
- <jitthreading>` to ensure that side exits and the like do not accidentally
2198
- result in concurrent LLVM API calls.
2199
-
2200
2173
.. _shutdown :
2201
2174
2202
2175
Ending Execution with ``llvm_shutdown() ``
2203
2176
-----------------------------------------
2204
2177
2205
2178
When you are done using the LLVM APIs, you should call ``llvm_shutdown() `` to
2206
- deallocate memory used for internal structures. This will also invoke
2207
- ``llvm_stop_multithreaded() `` if LLVM is operating in multithreaded mode. As
2208
- such, ``llvm_shutdown() `` requires the same isolation guarantees as
2209
- ``llvm_stop_multithreaded() ``.
2210
-
2211
- Note that, if you use scope-based shutdown, you can use the
2212
- ``llvm_shutdown_obj `` class, which calls ``llvm_shutdown() `` in its destructor.
2179
+ deallocate memory used for internal structures.
2213
2180
2214
2181
.. _managedstatic :
2215
2182
2216
2183
Lazy Initialization with ``ManagedStatic ``
2217
2184
------------------------------------------
2218
2185
2219
2186
``ManagedStatic `` is a utility class in LLVM used to implement static
2220
- initialization of static resources, such as the global type tables. Before the
2221
- invocation of `` llvm_shutdown() `` , it implements a simple lazy initialization
2222
- scheme. Once `` llvm_start_multithreaded() `` returns , however, it uses
2187
+ initialization of static resources, such as the global type tables. In a
2188
+ single-threaded environment , it implements a simple lazy initialization scheme.
2189
+ When LLVM is compiled with support for multi-threading , however, it uses
2223
2190
double-checked locking to implement thread-safe lazy initialization.
2224
2191
2225
- Note that, because no other threads are allowed to issue LLVM API calls before
2226
- ``llvm_start_multithreaded() `` returns, it is possible to have
2227
- ``ManagedStatic ``\ s of ``llvm::sys::Mutex ``\ s.
2228
-
2229
2192
.. _llvmcontext :
2230
2193
2231
2194
Achieving Isolation with ``LLVMContext ``
0 commit comments