[LLVMdev] getting started with IR needing GC

Terence Parr parrt at cs.usfca.edu
Sun Apr 20 17:08:49 PDT 2008


Howdy do LLVM folks!

I've exhausted what I can do on my own to make a GC example bind  
(usual googling, reading, playing, looking at source). I can't find  
the shadow collector lib or perhaps the -l options needed to link my  
sample (not even to point where I'm figuring out GC actually as I  
can't link).  Not sure this IR is correct but here is what I've been  
playing with (gc.ll):

declare void @llvm.gcroot(i8 **, i8*)
declare void @llvm_gc_collect()

define void @foo() gc "shadow-stack" {
; int *pa = malloc(sizeof(int));
     %a = malloc i32
     %pa = alloca i32*
     store i32* %a, i32** %pa

     %c = bitcast i32** %pa to i8**
     call void @llvm.gcroot(i8** %c, i8* null)
; *pa = 99;
     %t0 = add i32 99,0
     %t1 = load i32** %pa
     ;%t2 = getelementptr i32** %t1, i32 0
     store i32 %t0, i32* %t1

     store i32* null, i32** %pa; say it's dead
     ret void
}

define void @main() {
     call void @foo()
     call void @llvm_gc_collect()
     ret void
}

Naturally I find ShadowStackCollector.cpp but even crazy links like  
this:

gcc -lLLVMLinker -lLLVMipo /usr/local/lib/LLVMInterpreter.o - 
lLLVMInstrumentation /usr/local/lib/LLVMExecutionEngine.o /usr/local/ 
lib/LLVMJIT.o -lLLVMDebugger -lLLVMBitWriter /usr/local/lib/LLVMX86.o  
-lLLVMSelectionDAG -lLLVMCodeGen -lLLVMScalarOpts - 
lLLVMTransformUtils -lLLVMipa -lLLVMAsmParser -lLLVMArchive - 
lLLVMBitReader -lLLVMAnalysis -lLLVMTarget -lLLVMCore -lLLVMSupport - 
lLLVMSystem /usr/local/llvm-2.2/lib/CodeGen/Release/ 
ShadowStackCollector.o gc.s

don't find the llvm_gc_collect.  Tried my best to do a strings on all  
libs to find...must be out of C++ practice.  Clearly I'm including  
the compiler not runtime stuff above, but trying everything.

Can anybody help a guy out?

Terence




More information about the llvm-dev mailing list