Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 4641b6b

Browse files
author
Zachary Turner
committed
Programmer's Manual changes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211070 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 9020dc3 commit 4641b6b

File tree

1 file changed

+4
-47
lines changed

1 file changed

+4
-47
lines changed

docs/ProgrammersManual.rst

Lines changed: 4 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2170,67 +2170,24 @@ compiler, consider compiling LLVM and LLVM-GCC in single-threaded mode, and
21702170
using the resultant compiler to build a copy of LLVM with multithreading
21712171
support.
21722172

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-
22002173
.. _shutdown:
22012174

22022175
Ending Execution with ``llvm_shutdown()``
22032176
-----------------------------------------
22042177

22052178
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.
2213-
2179+
deallocate memory used for internal structures.
22142180
.. _managedstatic:
22152181

22162182
Lazy Initialization with ``ManagedStatic``
22172183
------------------------------------------
22182184

22192185
``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
2186+
initialization of static resources, such as the global type tables. In a
2187+
single-threaded environment, it implements a simple lazy initialization scheme.
2188+
When LLVM is compiled with support for multi-threading, however, it uses
22232189
double-checked locking to implement thread-safe lazy initialization.
22242190

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-
The ``llvm_acquire_global_lock()`` and ``llvm_release_global_lock`` APIs provide
2230-
access to the global lock used to implement the double-checked locking for lazy
2231-
initialization. These should only be used internally to LLVM, and only if you
2232-
know what you're doing!
2233-
22342191
.. _llvmcontext:
22352192

22362193
Achieving Isolation with ``LLVMContext``

0 commit comments

Comments
 (0)