[LLVMdev] CollectorRegistry

Gordon Henriksen gordonhenriksen at me.com
Wed Jul 23 20:12:10 PDT 2008


On 2008-07-23, at 11:48, Simon Ask Ulsnes wrote:

> Thank you for that clarification.
>
>> The framework decides which Collector to use based upon the 'gc'  
>> attribute of a function:
>>
>> define void @f() gc "mygc" {
>>  ...
>> }
>
> OK, so for instance if I wanted to be able to use the GC from a C  
> frontend (presumably by using llvm_gc_allocate?), do the C functions  
> need this attribute as well?

Yes.

> And if so, can this attribute be applied to functions in bitcode  
> compiled by llvm-gcc, without modifications to the C compiler or the  
> output bitcode?
> I.e., I use a custom driver program similar to lli that loads in  
> bitcode and my GC, and executes it, and ideally programs would be  
> able to use the GC without needing bitcode-level modifications (it's  
> perfectly ok to have to replace calls to malloc, though).

I would say that accurate GC would generally require considerable  
cooperation from the front-end compiler, which GCC does not  
particularly provide. But you could experiment with it. Simply adding  
a GC attribute to an existing function should generally be harmless  
(e.g., the inliner will do so inlining a function with GC into a  
function without), but doing so won't annotate the roots in the  
function.

— Gordon





More information about the llvm-dev mailing list