[llvm-dev] RFC: Strong GC References in LLVM

Sanjoy Das via llvm-dev llvm-dev at lists.llvm.org
Mon Jul 11 16:26:45 PDT 2016

Hi Eli,

Eli Friedman wrote:
 > I'm not really convinced that the GCREF type is really necessary...
 > consider an alternate model:
 > 1. A GCREF is never loaded into a register; it's either on the heap, or
 > in an alloca.
 > 2. Add an intrinsic gcref.copy which copies a gcref between two allocas.
 > 3. Add intrinsics gcref.load_gcref(GCREF*, GCREF*, offset) and
 > gcref.store_gcref(GCREF*, GCREF*, offset, value) which load and store a
 > gcref through a gcref.
 > 4. Add intrinsics gcref.load_value(GCREF*, offset) and
 > gcref.store_value(GCREF*, offset, value) which load and store normal
 > values a gcref.
 > 5. The statepoint lowering pass gets rid of the allocas.

This is similar to what we used to call "early safepoint insertion",
but ...

 > Keeping GCREFs exclusively in memory means the LLVM optimizer will
 > handle them conservatively, but correctly.
 > I guess the problem with this is precisely that the LLVM optimizer will
 > handle them conservatively...

... yup.  We _want_ LLVM to optimize well.

 > but on the flip side, I think you're going
 > to end up chasing down weird problems forever if a "load" from an alloca
 > has side-effects.

I need to carefully think through this before committing to it, but I
think we're generally okay with completely disallowing allocas of
GCREF type (like we do for token types today).  If we could do that
is your concern addressed?

-- Sanjoy

More information about the llvm-dev mailing list