[LLVMdev] Thread local data and atomic instructions

Jon Harrop jon at ffconsultancy.com
Sat Nov 21 10:37:14 PST 2009


I'm just dabbling with threads for the first time and have hit a few problems.

I need a shadow stack per thread and I'm not sure how to do that. Passing it 
everywhere seems like a bad idea. I could put it in a global thread id -> 
thread-local data mapping but that would incur lookup and locking every time 
I fiddle with it (which is often!). Is it possible for me to create a global 
using LLVM and mark it as thread local and use that instead?

Less importantly, I'd like to use atomic instructions to push my state machine 
around (for suspending and resuming mutators) and, although I can see 
llvm.atomic.cmp.swap in the LLVM Language Reference, I cannot see how to emit 
these atomic instructions from my compiler in the APIs. How is this done?

-- 
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e



More information about the llvm-dev mailing list