[LLVMdev] Using gcroot with value types
viridia at gmail.com
Mon Apr 26 17:20:49 CDT 2010
On Mon, Apr 26, 2010 at 12:44 AM, Paul Melis <llvm at assumetheposition.nl>wrote:
> Talin wrote:
> > 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
> > must be an alloca (which is always a pointer by definition) or an alloca
> > *of* a pointer.
> I'm pretty sure it should be "alloca of a pointer", as the first argument
> of llvm.gcroot has type i8**.
> However, http://llvm.org/docs/GarbageCollection.html#gcroot, isn't
> completely clear on this:
> "The first argument must be a value referring to an alloca instruction or
> a bitcast of an alloca."
> This last sentence seems to rule out passing GEPs on alloca's to
> > 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,
> > don't want to add the struct itself as a root, since it isn't allocated
> > 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.
> As reasonable as the above sounds, I don't think you can mark roots
> contained in structs. But if I'm wrong I'd love to know ;-) Perhaps you
> can ask the LDC devs how/if they handle this case, as it seems you can
> allocate a class instance on the stack in D.
> Ugh. If all roots have to be singleton pointers, not embedded within a
larger structure, then I'm not sure that what I want to do is even possible.
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the LLVMdev