[Mesa-dev] [PATCH] radeon/llvm: Don't use the global context when parsing LLVM IR

Tom Stellard tom at stellard.net
Thu May 2 15:25:53 PDT 2013


From: Tom Stellard <thomas.stellard at amd.com>

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 | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/radeon/radeon_llvm_util.c b/src/gallium/drivers/radeon/radeon_llvm_util.c
index 2582d9c..e3b0d63 100644
--- a/src/gallium/drivers/radeon/radeon_llvm_util.c
+++ b/src/gallium/drivers/radeon/radeon_llvm_util.c
@@ -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;
 }
 
-- 
1.8.1.5



More information about the mesa-dev mailing list