@@ -15,14 +15,14 @@ garbage collector.** You must provide your own.
1515Quick Start
1616============
1717
18- First, you should pick a collector strategy. LLVM includes a number of built
19- in ones, but you can also implement a loadable plugin with a custom definition.
18+ First, you should pick a collector strategy. LLVM includes a number of built-in
19+ ones, but you can also implement a loadable plugin with a custom definition.
2020Note that the collector strategy is a description of how LLVM should generate
2121code such that it interacts with your collector and runtime, not a description
2222of the collector itself.
2323
2424Next, mark your generated functions as using your chosen collector strategy.
25- From c ++, you can call:
25+ From C ++, you can call:
2626
2727.. code-block :: c++
2828
@@ -40,7 +40,7 @@ When generating LLVM IR for your functions, you will need to:
4040
4141* Use ``@llvm.gcread `` and/or ``@llvm.gcwrite `` in place of standard load and
4242 store instructions. These intrinsics are used to represent load and store
43- barriers. If you collector does not require such barriers, you can skip
43+ barriers. If your collector does not require such barriers, you can skip
4444 this step.
4545
4646* Use the memory allocation routines provided by your garbage collector's
@@ -49,7 +49,7 @@ When generating LLVM IR for your functions, you will need to:
4949* If your collector requires them, generate type maps according to your
5050 runtime's binary interface. LLVM is not involved in the process. In
5151 particular, the LLVM type system is not suitable for conveying such
52- information though the compiler.
52+ information through the compiler.
5353
5454* Insert any coordination code required for interacting with your collector.
5555 Many collectors require running application code to periodically check a
@@ -59,7 +59,7 @@ When generating LLVM IR for your functions, you will need to:
5959You will need to identify roots (i.e. references to heap objects your collector
6060needs to know about) in your generated IR, so that LLVM can encode them into
6161your final stack maps. Depending on the collector strategy chosen, this is
62- accomplished by using either the ``@llvm.gcroot `` intrinsics or an
62+ accomplished by using either the ``@llvm.gcroot `` intrinsics or a
6363``gc.statepoint `` relocation sequence.
6464
6565Don't forget to create a root for each intermediate value that is generated when
@@ -142,11 +142,11 @@ Perl, Python, Lua, Ruby, other scripting languages, and more.
142142
143143Note that LLVM **does not itself provide a garbage collector ** --- this should
144144be part of your language's runtime library. LLVM provides a framework for
145- describing the garbage collectors requirements to the compiler. In particular,
145+ describing the garbage collector's requirements to the compiler. In particular,
146146LLVM provides support for generating stack maps at call sites, polling for a
147147safepoint, and emitting load and store barriers. You can also extend LLVM -
148148possibly through a loadable :ref: `code generation plugins <plugin >` - to
149- generate code and data structures which conforms to the *binary interface *
149+ generate code and data structures which conform to the *binary interface *
150150specified by the *runtime library *. This is similar to the relationship between
151151LLVM and DWARF debugging info, for example. The difference primarily lies in
152152the lack of an established standard in the domain of garbage collection --- thus
@@ -185,10 +185,10 @@ adequately addressed with other features of the IR and does not specify a
185185particular binary interface. On the plus side, this means that you should be
186186able to integrate LLVM with an existing runtime. On the other hand, it can
187187have the effect of leaving a lot of work for the developer of a novel
188- language. We try to mitigate this by providing built in collector strategy
188+ language. We try to mitigate this by providing built- in collector strategy
189189descriptions that can work with many common collector designs and easy
190190extension points. If you don't already have a specific binary interface
191- you need to support, we recommend trying to use one of these built in collector
191+ you need to support, we recommend trying to use one of these built- in collector
192192strategies.
193193
194194.. _gc_intrinsics :
@@ -257,16 +257,16 @@ associated with the pointer, and **must** be a constant or global value
257257address. If your target collector uses tags, use a null pointer for metadata.
258258
259259A compiler which performs manual SSA construction **must ** ensure that SSA
260- values representing GC references are stored in to the alloca passed to the
260+ values representing GC references are stored into the alloca passed to the
261261respective ``gcroot `` before every call site and reloaded after every call.
262262A compiler which uses mem2reg to raise imperative code using ``alloca `` into
263263SSA form need only add a call to ``@llvm.gcroot `` for those variables which
264264are pointers into the GC heap.
265265
266266It is also important to mark intermediate values with ``llvm.gcroot ``. For
267267example, consider ``h(f(), g()) ``. Beware leaking the result of ``f() `` in the
268- case that ``g() `` triggers a collection. Note, that stack variables must be
269- initialized and marked with ``llvm.gcroot `` in function's prologue.
268+ case that ``g() `` triggers a collection. Note that stack variables must be
269+ initialized and marked with ``llvm.gcroot `` in the function's prologue.
270270
271271The ``%metadata `` argument can be used to avoid requiring heap objects to have
272272'isa' pointers or tag bits. [Appel89 _, Goldberg91 _, Tolmach94 _] If specified,
@@ -388,10 +388,10 @@ greater performance impact since pointer reads are more frequent than writes.
388388
389389.. _builtin-gc-strategies :
390390
391- Built In GC Strategies
391+ Built- In GC Strategies
392392======================
393393
394- LLVM includes built in support for several varieties of garbage collectors.
394+ LLVM includes built- in support for several varieties of garbage collectors.
395395
396396The Shadow Stack GC
397397----------------------
@@ -481,17 +481,17 @@ data structure, but there are only 20 lines of meaningful code.)
481481 }
482482
483483
484- The 'Erlang' and 'Ocaml ' GCs
484+ The 'Erlang' and 'OCaml ' GCs
485485-----------------------------
486486
487487LLVM ships with two example collectors which leverage the ``gcroot ``
488488mechanisms. To our knowledge, these are not actually used by any language
489489runtime, but they do provide a reasonable starting point for someone interested
490490in writing an ``gcroot `` compatible GC plugin. In particular, these are the
491- only in tree examples of how to produce a custom binary stack map format using
491+ only in- tree examples of how to produce a custom binary stack map format using
492492a ``gcroot `` strategy.
493493
494- As there names imply, the binary format produced is intended to model that
494+ As their names imply, the binary format produced is intended to model that
495495used by the Erlang and OCaml compilers respectively.
496496
497497.. _statepoint_example_gc :
@@ -544,14 +544,14 @@ certain aspects like:
544544Custom GC Strategies
545545====================
546546
547- If none of the built in GC strategy descriptions met your needs above, you will
547+ If none of the built- in GC strategy descriptions met your needs above, you will
548548need to define a custom GCStrategy and possibly, a custom LLVM pass to perform
549549lowering. Your best example of where to start defining a custom GCStrategy
550- would be to look at one of the built in strategies.
550+ would be to look at one of the built- in strategies.
551551
552552You may be able to structure this additional code as a loadable plugin library.
553553Loadable plugins are sufficient if all you need is to enable a different
554- combination of built in functionality, but if you need to provide a custom
554+ combination of built- in functionality, but if you need to provide a custom
555555lowering pass, you will need to build a patched version of LLVM. If you think
556556you need a patched build, please ask for advice on llvm-dev. There may be an
557557easy way we can extend the support to make it work for your use case without
@@ -576,7 +576,7 @@ You should be able to leverage any existing collector library that includes the
576576#. A mechanism for identifying references in global locations (e.g. global
577577 variables).
578578
579- #. If you collector requires them, an LLVM IR implementation of your collectors
579+ #. If your collector requires them, an LLVM IR implementation of your collector's
580580 load and store barriers. Note that since many collectors don't require
581581 barriers at all, LLVM defaults to lowering such barriers to normal loads
582582 and stores unless you arrange otherwise.
@@ -598,7 +598,7 @@ runtime library). This can be accomplished in about 100 lines of code.
598598This is not the appropriate place to implement a garbage collected heap or a
599599garbage collector itself. That code should exist in the language's runtime
600600library. The compiler plugin is responsible for generating code which conforms
601- to the binary interface defined by library, most essentially the :ref: `stack map
601+ to the binary interface defined by the library, most essentially the :ref: `stack map
602602<stack-map>`.
603603
604604To subclass ``llvm::GCStrategy `` and register it with the compiler:
@@ -850,11 +850,11 @@ Custom lowering of intrinsics
850850------------------------------
851851
852852For GCs which use barriers or unusual treatment of stack roots, the
853- implementor is responsibly for providing a custom pass to lower the
853+ implementor is responsible for providing a custom pass to lower the
854854intrinsics with the desired semantics. If you have opted in to custom
855855lowering of a particular intrinsic your pass **must ** eliminate all
856856instances of the corresponding intrinsic in functions which opt in to
857- your GC. The best example of such a pass is the ShadowStackGC and it's
857+ your GC. The best example of such a pass is the ShadowStackGC and its
858858ShadowStackGCLowering pass.
859859
860860There is currently no way to register such a custom lowering pass
0 commit comments