Using gcroot with value types

I’m a little confused as to the rules for the arguments to llvm.gcroot, which says it must be a pointer alloca. I’m not sure whether that means it must be an alloca (which is always a pointer by definition) or an alloca of a pointer.

What I am trying to figure out is how to declare roots contained in value types. Suppose for example I have a small struct which contains several garbage-collectable references. This struct is a local variable, so it’s contained in a block of memory which has been allocated via alloca. Now, I don’t want to add the struct itself as a root, since it isn’t allocated on the heap. But I want to declare the fields within the struct - which are GEPs from the alloca pointer - as roots, since they are references to objects on the heap.

Unfortunately, when I attempt to pass a GEP of an alloca into llvm.gcroot, it complains. OK, so instead I’ll pass the address of the whole struct into llvm.gcroot, with some metadata telling it the offsets of the collectable fields. But that doesn’t work either - in both cases, it says that “llvm.gcroot parameter #1 must be a pointer alloca.”

– Talin