PassRegistry and multi-thread


The llvm documentation specify that :
“PassRegistry is NOT thread-safe. If you want to use LLVM on multiple threads simultaneously, you will need to use a separate PassRegistry on each thread.”

I have some code that create a module, run some optimizations using the llvm::legacy::FunctionPassManager and llvm::legacy::PassManager, and then jit the code with an execution engine.
If I create my own PassRegistry and initialize pass like:

PassRegistry* Registry = new llvm::PassRegistry();
… etc …

Using my passregistry, my program crash in :
const PassInfo *PI = findAnalysisPassInfo(*I); → which is calling the global PassRegistry

So how can I tell the FunctionPassManager to use my PassRegistry instead of the global pass registry? What am I missing here?

Any help will be appreciated.