[LLVMdev] Marking *some* pointers for gc
Sanjoy Das
sanjoy at playingwithpointers.com
Sat Jan 17 17:41:46 PST 2015
On Sat, Jan 17, 2015 at 4:12 PM, Ramkumar Ramachandra
<artagnon at gmail.com> wrote:
> Hi,
>
> I just found out that it's not practical to mark only some pointers
> for GC. Consider:
>
> %a = i8 addrspace(1)* malloc(...)
> %b = i8* alloca(...)
>
> The issue then becomes that routine functions declared:
>
> declare i1 foo(i8 addrspace(1)*)
>
> have a choice of accepting either gc'able or non-gc'able pointers. Is
> there no way to have a reasonable mix of both?
Part of the reason for putting GC'able pointers in addrspace 1 is to
have a *strong* distinction (or as strong as LLVM IR will let us have)
between GC-able and non-GC pointers -- it is not a coincidence that
you cannot "forget" (ruling out addrspacecast) that a pointer is
GC-able and pass it to a function that does not expect a GC-able
pointer. For instance, you cannot dereference a GC-able pointer after
passing a safepoint that did not relocate the GC-able pointer; and
your GC probably cannot relocate non-GC'able pointers. In your
example, foo will have to treat its argument differently depending on
whether it is a GC pointer or not.
Does this answer your question?
>
> Ram
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
More information about the llvm-dev
mailing list