splitting up program into multiple threads

I have a sort of strange request -- I am splitting up a program
into multiple threads, which may have duplicated instructions between
them. I'd like to run optimizations on the threads separately, but I'd
like for the variables common amongst the threads to get register
allocated the same way (i.e, a value that is duplicated in the two threads
gets mapped to the same register/memory location). Is there a cleaner way
to this other than to make all the shared variables global? Thanks in
advance for any advice.

It sounds like you are generating separate code for the different
threads, if you plan ot optimize them separately.

If that's true, it's not clear exactly what you want since LLVM
distinguishes registers and memory and there is no correspondence
between them. When you say a common variable, do you mean a variable in
memory (i.e., global or alloca slot), or an SSA register?

If you know that you want SSA registers r1 and r2 in 2 different threads
to be mapped to the same register, you can give the RegAlloc pass hints
to suggest which register to use. These are not guaranteed but unless
you have high register pressure, the hints are likely to be respected.
Then, if the hints are not respected, you could force this "variable" to
be a global.

Let's take this discussion off the llvmdev list. If anyone else has any
suggestions, please send them to Francesco directly and copy me.

--Vikram
http://www.cs.uiuc.edu/~vadve