[LLVMdev] GC questions.

Tobias Nurmiranta spyck at lysator.liu.se
Mon Jul 19 05:47:20 PDT 2004


Regarding llvm.gcroot, do I have to allocate stack-space for all pointers
in a function? Right now I mostly use SSA-variables, and let llvm's
register allocation allocate stack-space when needed. Also, what happens
when I run the mem2reg pass, does it handle llvm.gcroot's that are moved
from stack to registers?

I'm thinking along the lines, that should one not use llvm.gcroot on all
SSA-variables that contains pointers to objects, and then depending on if
the variables end up on the stack, or in registers, the compiler will use

All my objects are currently typetagged uint's. My llvm scheme code in
the compiler explains this I think:

     (llvm-define (make-number x) (bit-shl x 2))
     (llvm-define (raw-number x) (bit-shr x 2))
     (llvm-define (clear-tag x) (bit-shl (bit-shr x 2) 2))
     (llvm-define (get-tag x) (bit-and x 3))
     (llvm-define (make-pointer x) (bit-or (clear-tag x) 1))
     (llvm-define (make-function-pointer x) (bit-or (clear-tag x) 3))
     (llvm-define (points-to x) (clear-tag x))
     (llvm-define (number? x) (seteq (get-tag x) 0))
     (llvm-define (vector? x) (seteq (get-tag x) 1))
     (llvm-define (procedure? x) (seteq (get-tag x) 3))

     (llvm-define (make-vector raw-size)
                   (cast "uint*" (store raw-size (malloc (add raw-size 1))) "uint")))

,	Tobias

More information about the llvm-dev mailing list