[LLVMdev] GC questions.
spyck at lysator.liu.se
Thu Jul 22 04:57:57 PDT 2004
On Thu, 22 Jul 2004, Chris Lattner wrote:
> > While I was editing LowerGC.cpp I made a little test (not part of this
> > patch, but the diff with LowerGC.cpp in cvs is attached). I've added a new
> > intrinsic called llvm.gcroot_value(sbyte*, sbyte*), which takes a pointer
> > directly instead and transforms it into an alloca. The idea is the
> > In this way, the frontends don't have to explictly alloca the gcroots,
> > but instead just use the intrinsic, which hides how the gcroots are
> > implemented.
> Unfortunately this won't really work. It might be reasonable to include
> something like this in the front-end that you're working on, but including
> this at the LLVM level is a bad idea. The basic idea of the alloca model
> is that it directly exposes to the optimizer the fact that GC pointers may
> change at unpredictable times, which is something that memory can do, but
> SSA registers do not do.
Ok. But if the gcroot_value transformation in done before any
optimizations, I get the same result as if I had used gcroot and alloca.
So maybe I can move it to a independent pass which I then use with my
Hmm, it felt nicer to mark raw LLVM pointers as roots and then transform
them, since I then didn't have to see the overhead in my frontend :).
Btw, how hard would it be to implement the system described in this
paper, support for collection at every instruction? You would need to
get the gc root information with you all the way down to machine code and
register allocation. Just curious :).
More information about the llvm-dev