radeon/llvm: Don't use the global context when parsing LLVM IR

This leads to crashes when multiple threads try to compile compute
shaders in the same time.

Fixes a crash in bfgminer when using more than one thread.
This commit is contained in:
Tom Stellard 2013-05-02 18:25:53 -04:00
parent bd850cb4f2
commit 7cc98ea88f

View file

@ -34,11 +34,12 @@ LLVMModuleRef radeon_llvm_parse_bitcode(const unsigned char * bitcode,
unsigned bitcode_len)
{
LLVMMemoryBufferRef buf;
LLVMModuleRef module = LLVMModuleCreateWithName("radeon");
LLVMContextRef ctx = LLVMContextCreate();
LLVMModuleRef module;
buf = LLVMCreateMemoryBufferWithMemoryRangeCopy((const char*)bitcode,
bitcode_len, "radeon");
LLVMParseBitcode(buf, &module, NULL);
LLVMParseBitcodeInContext(ctx, buf, &module, NULL);
return module;
}