<div dir="ltr"><div>Hello LLVM community,</div><div><br></div><div>We have been experimenting with using LLVM IR as a target for a managed (dynamically typed) language via an AOT compiler (including a backend for ARM). One main challenge is getting the garbage collection right: We would like to be able to implement a moving collector. This requires us to a) find a precise set of root pointers and b) be able to rewrite those pointers after objects moved.</div><div><br></div><div>LLVM seems to provide two mechanisms for doing this: via "gcroot" and via "statepoints". The [statepoints] documentation indicates the first option, namely "gcroot", is only viable for conservative collectors and statepoints might eventually replace gcroot. So we wanted to try out the statepoints approach.</div><div><br></div><div>Though it turned out that:</div><div>  * the pass for inserting statepoints is hard-coded to only work with samples and CLR (see [placesafepoints])</div><div>  * the pass for rewriting statepoints is hard-coded to only work with samples and CLR (see [rewritestatepoints])<br></div><div>  * the only backend supporting statepoints right now seems to be 64-bit intel (see [backend-x64])</div><div><br></div><div>Since the ARM backend (and e.g. 32-bit intel) doesn't seem to have support for lowering statepoints-using IR, we were rather disappointed.</div><div><br></div><div>We are now experimenting with keeping a shadow stack which contains all the managed pointers, but since the IR we emit contains reads/write to this shadow stack (and the shadow stack escapes on calls), the performance suffers significantly, since LLVM can't perform a lot of the optimizations it could otherwise do (IIRC the statepoints approach doesn't have this problem, since the statepoints can be inserted *after* optimization passes were run).</div><div><br></div><div>Is there any timeline for the statepoints support in LLVM?</div><div>Is there a list of things that currently work / don't work with safepoints?</div><div>What is the recommended approach for moving GCs when using LLVM (what are others doing)?</div><div><br></div><div>Thanks in advance,</div><div>Martin</div><div><br></div><div>Sidenote: It would be beneficial for users if the [statepoints] documentation would highlight the current status and limitations.</div><div><br></div><div>[statepoints] <a href="http://llvm.org/docs/Statepoints.html" target="_blank">http://llvm.org/docs/Statepoints.html</a></div><div>[placesafepoints] <a href="https://github.com/llvm-mirror/llvm/blob/a40ba754c3f765768d441b9b4b534da917f8ad3c/lib/Transforms/Scalar/PlaceSafepoints.cpp#L441" target="_blank">https://github.com/llvm-mirror/llvm/blob/a40ba754c3f765768d441b9b4b534da917f8ad3c/lib/Transforms/Scalar/PlaceSafepoints.cpp#L441</a><br></div><div>[rewritestatepoints] <a href="https://github.com/llvm-mirror/llvm/blob/a40ba754c3f765768d441b9b4b534da917f8ad3c/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp#L2286" target="_blank">https://github.com/llvm-mirror/llvm/blob/a40ba754c3f765768d441b9b4b534da917f8ad3c/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp#L2286</a><br></div><div>[backend-x64] <a href="https://github.com/llvm-mirror/llvm/blob/a40ba754c3f765768d441b9b4b534da917f8ad3c/lib/Target/X86/X86MCInstLower.cpp#L841" target="_blank">https://github.com/llvm-mirror/llvm/blob/a40ba754c3f765768d441b9b4b534da917f8ad3c/lib/Target/X86/X86MCInstLower.cpp#L841</a></div></div>