Remove global lock for LLVM state

This uses a lock on the shared state so we don't have a global lock
there. Also switches to a spinlock for this case.