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? Ram
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
Sanjoy Das wrote:> In your > example, foo will have to treat its argument differently depending on > whether it is a GC pointer or not.In practice, this is not true of many functions that don't call other functions. Take the example of a simple "print" function that takes a void * to cast and print, type_int to determine what to cast to: why should it care about whether the pointer is GC'able or not? In the callsite, I have this information, and I accordingly emit statepoint/relocate information. But "print" doesn't call other functions, and doesn't need to emit statepoint/relocate. Let's say I made the void * argument addrspace(0). Then, in callsites where I have an addrspace(1) to pass, I have to emit: addrspacecast 1 -> 0 call print addrspacecast 0 -> 1 Is the ideal workflow, or should we have some sort of addrspaceany?
Maybe Matching Threads
- [LLVMdev] Marking *some* pointers for gc
- [LLVMdev] [INCOMPLETE] [GC] Support wrapping vararg functions in statepoint
- [LLVMdev] How to test isDereferenceablePointer?
- [LLVMdev] How to test isDereferenceablePointer?
- [LLVMdev] [INCOMPLETE] [GC] Support wrapping vararg functions in statepoint