[LLVMdev] Why LLVM should NOT have garbage collection intrinsics[MESSAGE NOT SCANNED]

Mark Shannon marks at dcs.gla.ac.uk
Fri Feb 27 03:38:08 PST 2009


Hi,

I realise this might be a bit controversial ;)

Suppose I am writing a VM (such as VMKit), or a VM toolkit, and I want 
to add a generational GC.

If I want to use the llvm.gcwrite intrinsic for my write barrier then
I need to write a GC and then implement for each and *every* backend the 
gcwrite intrinsic for my write barrier.

Now, if I don't use the intrinsic, I need to write my write barrier 
*once* in llvm IR. All I need is a nop intrinsic and ensure that all 
objects collectable by the GC are reachable from some global variable.
This ensures that the optimisation phases know that they cannot rely on 
memory objects not moving at GC safe points.

I have a *copying* collector that works with llvm JITted code, so I know 
that this works :)

In fact, this leads to a more general point:
ANY intrinsic that is not guaranteed to be implemented by ALL backends 
is useless, since a front-end that uses llvm to target multiple 
architectures MUST avoid them.

Mark.



More information about the llvm-dev mailing list