I'm in a group tasked with improving the GC of LLVM for a 421 project. We are having trouble getting started with the given SemiSpace collector. We found the string llvm_gc_initialize called from a single source file ./test/Regression/CodeGen/Generic/GC/alloc_loop.ll which we tried with the following... (showing LLVM checked out from cvs a few days ago, similar output with release 1.3) $ llvm-as alloc_loop.ll $ lli alloc_loop.bc lli: Globals.cpp:81: llvm::GlobalVariable::GlobalVariable(const llvm::Type*, bool, llvm::GlobalValue::LinkageTypes, llvm::Constant*, const std::string&, llvm::Module*): Assertion `Initializer->getType() == Ty && "Initializer should be the same type as the GlobalVariable!"' failed. lli((anonymous namespace)::PrintStackTrace()+0x1a)[0x857f21a] lli((anonymous namespace)::SignalHandler(int)+0xcb)[0x857f48d] [0xffffe420] lli((anonymous namespace)::LowerGC::doInitialization(llvm::Module&)+0x56d)[0x83ed459] lli(llvm::PassManagerTraits<llvm::Function>::doInitialization(llvm::Module&)+0x56)[0x84de43a] lli(llvm::FunctionPass::run(llvm::Function&)+0x4c)[0x848e720] lli(llvm::FunctionPassManager::run(llvm::Function&)+0xe7)[0x848dcdd] lli(llvm::JIT::runJITOnFunction(llvm::Function*)+0x4f)[0x8312da7] lli(llvm::JIT::getPointerToFunction(llvm::Function*)+0x15f)[0x8312f59] lli(llvm::JIT::runFunction(llvm::Function*, std::vector<llvm::GenericValue, std::allocator<llvm::GenericValue> > const&)+0x4e)[0x8311fc0] lli(llvm::ExecutionEngine::runFunctionAsMain(llvm::Function*, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, char const* const*)+0x2ef)[0x8369619] lli(main+0x26c)[0x82f89b0] /lib/tls/libc.so.6(__libc_start_main+0x108)[0x401307f8] Aborted How should we get this to run? Also the code in runtime/GC/SemiSpace/semispace.c doesn't seem to do anything other than call process_pointer for every gcroot pointer. static void process_pointer(void **Root, void *Meta) { printf("process_root[0x%p] = 0x%p\n", (void*) Root, (void*) *Root); } Are there any examples of LLVM performing active garbage collection? In the dev archives (http://mail.cs.uiuc.edu/pipermail/llvmdev/2004-July/001527.html) Chris said there are no frontends with GC support, but it might get into Java first. Where is llvm-java? Google didn't find it in top 10, there is no llvm-java module in cvs, find -iname java offered no hope. Do you recommend we stick to llvm assembly for testing GC? Tom -- 28 70 20 71 2C 65 29 61 9C B1 36 3D D4 69 CE 62 4A 22 8B 0E DC 3E mailto:tdbrown at uiuc.edu http://thecap.org/
On Tue, 26 Oct 2004, Tom Brown wrote:> I'm in a group tasked with improving the GC of LLVM for a 421 project. > We are having trouble getting started with the given SemiSpace > collector. > > We found the string llvm_gc_initialize called from a single source file > ./test/Regression/CodeGen/Generic/GC/alloc_loop.ll > which we tried with the following... (showing LLVM checked out from cvs a few days ago, similar > output with release 1.3) > > $ llvm-as alloc_loop.ll > $ lli alloc_loop.bc > lli: Globals.cpp:81: llvm::GlobalVariable::GlobalVariable(const llvm::Type*, bool, llvm::GlobalValue::LinkageTypes, llvm::Constant*, const std::string&, llvm::Module*): Assertion `Initializer->getType() == Ty && "Initializer should be the same type as the GlobalVariable!"' failed. > lli((anonymous namespace)::PrintStackTrace()+0x1a)[0x857f21a] > lli((anonymous namespace)::SignalHandler(int)+0xcb)[0x857f48d] > [0xffffe420] > How should we get this to run?Sorry about that, patch for this problem here: http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20041025/019891.html> Also the code in runtime/GC/SemiSpace/semispace.c doesn't seem to do > anything other than call process_pointer for every gcroot pointer. > > static void process_pointer(void **Root, void *Meta) { > printf("process_root[0x%p] = 0x%p\n", (void*) Root, (void*) *Root); > }Correct. The semispace collector hasn't been implemented all of the way. The code generator and runtime interfaces provide you with all of the hooks that you need to implement a garbage collector though.> Are there any examples of LLVM performing active garbage collection? In > the dev archives > (http://mail.cs.uiuc.edu/pipermail/llvmdev/2004-July/001527.html) Chris > said there are no frontends with GC support, but it might get into Java > first. Where is llvm-java? Google didn't find it in top 10, there is no > llvm-java module in cvs, find -iname java offered no hope.LLVM-Java is still in development unfortunately. I believe that array support is currently being added by Alkis and that he hasn't hooked it up with the GC yet.> Do you recommend we stick to llvm assembly for testing GC?Unfortunately, yes that's really the only way to go for now. -Chris -- http://llvm.org/ http://nondot.org/sabre/
On Tue, Oct 26, 2004 at 11:17:00PM -0500, Chris Lattner wrote:> On Tue, 26 Oct 2004, Tom Brown wrote: > > $ llvm-as alloc_loop.ll > > $ lli alloc_loop.bc > > lli: Globals.cpp:81: llvm::GlobalVariable::GlobalVariable(const llvm::Type*, bool, llvm::GlobalValue::LinkageTypes, llvm::Constant*, const std::string&, llvm::Module*): Assertion `Initializer->getType() == Ty && "Initializer should be the same type as the GlobalVariable!"' failed. > > lli((anonymous namespace)::PrintStackTrace()+0x1a)[0x857f21a] > > lli((anonymous namespace)::SignalHandler(int)+0xcb)[0x857f48d] > > [0xffffe420] > > How should we get this to run? > > Sorry about that, patch for this problem here: > http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20041025/019891.htmlThat patch does fix the problem. Thank you. I used the following llvm-link -f -o linked.bc alloc_loop.bc ~/llvm/runtime/GC/SemiSpace/Debug/semispace.bc because it seemed easier than working out if and how to get dynamic loading and linking to work. Perhaps the process will be smoother when I restart using projects/sample/ . Running linked.bc outputs Garbage collecting!! process_root[0x0xbffff3f0] = 0x0x41257008 process_root[0x0xbffff3ec] = 0x0x41257012 lli((anonymous namespace)::PrintStackTrace()+0x1a)[0x857f236] lli((anonymous namespace)::SignalHandler(int)+0xcb)[0x857f4a9] [0xffffe420] lli(llvm::ExecutionEngine::runFunctionAsMain... Which is too be expected since llvm_gc_collect in llvm/runtime/GC/SemiSpace/semispace.c ends with abort(); I believe we have our work cut out for us. Hopefully you'll have a working GC by Christmas time. Tom -- 28 70 20 71 2C 65 29 61 9C B1 36 3D D4 69 CE 62 4A 22 8B 0E DC 3E mailto:tdbrown at uiuc.edu http://thecap.org/