[LLVMdev] Garbage Collection

Paul van der Ende paende at cs.uu.nl
Thu Apr 8 07:15:27 PDT 2010


Thanks for the example code. Its gives a good idea how the shadow stack
works.

But I have another question. Using the shadow stack is a nice and simple
way to implement GC, but it might have a large runtime overhead per
function call. Is there another way to preserve garbage specific
information (gcroots) through the llvm optimizer and native code
generator? This information could be used to create static stack
descriptors.

Another question, is it easy to tell which optimizations will break static
stack descriptors? I guess the Mem2Reg will break it, but are there any
others? Or can the llc native code generator break the static stack
descriptors as well? It might be possible to just disable these specific
dangerous optimizations.

Greets,
Paul.


On Wed, Mar 31, 2010 at 9:08 PM, Paul Melis <llvm at assumetheposition.nl>
wrote:
> Hi Paul,
>
> On 03/25/10 12:15, Paul van der Ende wrote:
>> I want to add garbage collection support to a compiler with a llvm
>> backend, using the shadow-stack compiler plugin.
>>
>> I read the GC tutorial in the LLVM documentation, and the paper about
>> shadow-stacks. Im currently adding intrinsics to my generated llvm code,
>> and trying to write code to connected it to my (existing) garbage
>> collector library. Im not sure yet how everything fits together.
>>
>> Im particularly interested in how the llvm specific shadow-stack
>> transformation works to get a better understanding. Is it possible to
>> output the llvm instructions created from the gcroot intrinsics etc after
>> the transformation? At what compiler stage is the transformation
>> performed? I tried to find out what it does with the llvm instructions
>> from looking at the source code of the GCStrategy class, but I like to see
>> an example for my own code to see what is really happening. The llvm
>> specific cpp code is hard to understand because im not really a llvm
>> framework developer.
>>
>> Another question, the GC tutorial refers to
>> "/runtime/GC/SemiSpace/semispace.cpp" (a simple gc on top of the
>> shadow-stack) but this file does not exist in the 2.6 release, I was able
>> to find it in older releases. Is it out-dated? will there be an example
>> garbage collector in the 2.7 release?
>>
>> Are there any other code examples of garbage collectors written on top of
>> the llvm shadow stack?
>>
> I had a lot of the same questions as you and just tried to create some
> simple proof-of-concept implementation on top of LLVM, using a
> semi-space collector. I didn't look at details of GCStrategy back then,
> I merely used the LLVM @llvm.gcroot intrinsic (through llvm-gcc) and the
> built-in shadow stack support. Here's the code, perhaps it's useful for
> you. It's quite clean as I wanted something I could refer too in the
> future for myself. But it doesn't do anything else except allocate a few
> objects of some class type that reference each other and forces some
> collections.
>
> Hoop dat je er wat aan hebt,
> Paul
>
> _______________________________________________
> 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