[LLVMdev] Interactions with threads and native code
Evan Jones
ejones at uwaterloo.ca
Tue Feb 8 18:22:24 PST 2005
I have just begun investigating LLVM because it seems like it might be
an ideal tool for building tools for playing with software. However, my
current project is related to parallel programming on shared memory
multiprocessor systems, so I need thread support. As far as I can tell,
LLVM currently has no intrinsic support for threads, is this correct? I
saw the bug that indicates that LLVM's JIT needs some locks to protect
its data structures, but are there any other issues that might be
preventing LLVM from executing multithreaded applications?
To help me in my investigations, I wrote a small program that calls the
Linux clone system call. It turns out that this small test program
executes correctly with LLVM, which surprised me. Is this just because
I got lucky, or is this expected behaviour?
Does anyone have any thoughts about if or how LLVM should support
threads? I was thinking that it might be worthwhile to add a few thread
primitives to the llvm.* collection of instrinsics. Something like
llvm.spawn, llvm.join, llvm.lock, llvm.unlock, and llvm.cas would be
sufficient for my purposes.
Finally, how does LLVM interact with native code? I see in the
disassembly that it declares the prototype for the clone function, but
how does it locate the implementation? If it ends up calling "dlopen"
and "dlsym," how does it know which library to look in? Additionally,
is it possible to link against arbitrary native code libraries?
Thank you for your assistance,
Evan Jones
More information about the llvm-dev
mailing list