[LLVMdev] 2.2 garbage collector questions

Carl Friedrich Bolz cfbolz at gmx.de
Tue Feb 5 13:15:16 PST 2008


Jaap Suter wrote:
 >> LLVM currently lacks working examples demonstrating the use of garbage
 >> collection...
 >
 > Hello,
 >
 > if anybody has time, I would recommend putting a big disclaimer at 
the top of
 > the garbage collection page that explains that, for the most part, 
garbage
 > collection falls outside of LLVM's domain.
 >
 > Right now LLVM advertises itself as "supporting garbage collecting", 
which
 > although true, somewhat misses the point. LLVM just happens to not 
get in the
 > way. The only real garbage collection feature that LLVM provides is 
accurate
 > stack walking, and even that can be implemented separately through a 
shadow stack.
 >
 > That the documentation contains llvm.gc intrinsics is a bit of a red 
herring.
 > You end up doing most of the work yourself. To illustrate, for our 
own LLVM work
 > we implemented garbage collecting completely without using any LLVM 
primitives.
 > Granted, we're a conservative collector right now, and once we go 
accurate we'll
 > investigate the stack-walking.

In my opinion this is exactly what LLVM _should_ provide. If you try to
implement an exact GC one of the most annoying bits is getting
information about your stack roots. Using a shadow stack is possible but
there are costs attached to it (in PyPy we observed slowdowns of around
5%) as well as implementation complexity.

http://morepypy.blogspot.com/2008/01/finding-gc-roots-using-llvm-or-parsing.html


 > Just a head's up from an beginner/intermediate LLVM programmer. The 
current
 > state of the GC documentation makes it seem as if: "you just connect 
the GC and
 > it works". I'm sure that isn't the intention, but judging from some 
of the posts
 > on this mailing lists over the past months, this seems to be a common 
expectation.

Maybe a disclaimer would make sense indeed.

Cheers,

Carl Friedrich Bolz



More information about the llvm-dev mailing list