radeon/llvm: Don't use the global context when parsing LLVM IR
authorTom Stellard <thomas.stellard@amd.com>
Thu, 2 May 2013 22:25:53 +0000 (18:25 -0400)
committerTom Stellard <thomas.stellard@amd.com>
Mon, 6 May 2013 16:06:00 +0000 (09:06 -0700)
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.

src/gallium/drivers/radeon/radeon_llvm_util.c

index 2582d9cf118cba4f2da6065adcb3ffbb50de239d..e3b0d638b717a6ed7ce45be51fa0bdd4989121be 100644 (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;
 }