diff options
author | Aaron Watry <awatry@gmail.com> | 2013-12-12 16:34:09 -0600 |
---|---|---|
committer | Aaron Watry <awatry@gmail.com> | 2013-12-23 07:24:50 -0600 |
commit | 8c9a9205d96b5ac0718218bfa952a5b4b6ad939c (patch) | |
tree | 089a1cf74b6d22561955441e93a6dfc38f374d60 /src/gallium/drivers/radeon | |
parent | a7653c19a3b1adae162864587a7ab1c17ab256e6 (diff) | |
download | external_mesa3d-8c9a9205d96b5ac0718218bfa952a5b4b6ad939c.zip external_mesa3d-8c9a9205d96b5ac0718218bfa952a5b4b6ad939c.tar.gz external_mesa3d-8c9a9205d96b5ac0718218bfa952a5b4b6ad939c.tar.bz2 |
radeon/compute: Stop leaking LLVMContexts in radeon_llvm_parse_bitcode
Previously we were creating a new LLVMContext every time that we called
radeon_llvm_parse_bitcode, which caused us to leak the context every time
that we compiled a CL program.
Sadly, we can't dispose of the LLVMContext at the point that it was being
created because evergreen_launch_grid (and possibly the SI equivalent) was
assuming that the context used to compile the kernels was still available.
Now, we'll create a new LLVMContext when creating EG/SI compute state, store
it there, and pass it to all of the places that need it.
The LLVM Context gets destroyed when we delete the EG/SI compute state.
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
CC: "10.0" <mesa-stable@lists.freedesktop.org>
Diffstat (limited to 'src/gallium/drivers/radeon')
-rw-r--r-- | src/gallium/drivers/radeon/radeon_llvm_util.c | 15 | ||||
-rw-r--r-- | src/gallium/drivers/radeon/radeon_llvm_util.h | 9 |
2 files changed, 12 insertions, 12 deletions
diff --git a/src/gallium/drivers/radeon/radeon_llvm_util.c b/src/gallium/drivers/radeon/radeon_llvm_util.c index 3ba0acc..cf6d21e 100644 --- a/src/gallium/drivers/radeon/radeon_llvm_util.c +++ b/src/gallium/drivers/radeon/radeon_llvm_util.c @@ -33,11 +33,10 @@ #include <llvm-c/Transforms/IPO.h> #include <llvm-c/Transforms/PassManagerBuilder.h> -LLVMModuleRef radeon_llvm_parse_bitcode(const unsigned char * bitcode, - unsigned bitcode_len) +LLVMModuleRef radeon_llvm_parse_bitcode(LLVMContextRef ctx, + const unsigned char * bitcode, unsigned bitcode_len) { LLVMMemoryBufferRef buf; - LLVMContextRef ctx = LLVMContextCreate(); LLVMModuleRef module; buf = LLVMCreateMemoryBufferWithMemoryRangeCopy((const char*)bitcode, @@ -47,10 +46,10 @@ LLVMModuleRef radeon_llvm_parse_bitcode(const unsigned char * bitcode, return module; } -unsigned radeon_llvm_get_num_kernels(const unsigned char *bitcode, - unsigned bitcode_len) +unsigned radeon_llvm_get_num_kernels(LLVMContextRef ctx, + const unsigned char *bitcode, unsigned bitcode_len) { - LLVMModuleRef mod = radeon_llvm_parse_bitcode(bitcode, bitcode_len); + LLVMModuleRef mod = radeon_llvm_parse_bitcode(ctx, bitcode, bitcode_len); return LLVMGetNamedMetadataNumOperands(mod, "opencl.kernels"); } @@ -87,7 +86,7 @@ static void radeon_llvm_optimize(LLVMModuleRef mod) LLVMDisposePassManager(pass_manager); } -LLVMModuleRef radeon_llvm_get_kernel_module(unsigned index, +LLVMModuleRef radeon_llvm_get_kernel_module(LLVMContextRef ctx, unsigned index, const unsigned char *bitcode, unsigned bitcode_len) { LLVMModuleRef mod; @@ -95,7 +94,7 @@ LLVMModuleRef radeon_llvm_get_kernel_module(unsigned index, LLVMValueRef *kernel_metadata; unsigned i; - mod = radeon_llvm_parse_bitcode(bitcode, bitcode_len); + mod = radeon_llvm_parse_bitcode(ctx, bitcode, bitcode_len); num_kernels = LLVMGetNamedMetadataNumOperands(mod, "opencl.kernels"); kernel_metadata = MALLOC(num_kernels * sizeof(LLVMValueRef)); LLVMGetNamedMetadataOperands(mod, "opencl.kernels", kernel_metadata); diff --git a/src/gallium/drivers/radeon/radeon_llvm_util.h b/src/gallium/drivers/radeon/radeon_llvm_util.h index b851648..733c329 100644 --- a/src/gallium/drivers/radeon/radeon_llvm_util.h +++ b/src/gallium/drivers/radeon/radeon_llvm_util.h @@ -29,10 +29,11 @@ #include <llvm-c/Core.h> -LLVMModuleRef radeon_llvm_parse_bitcode(const unsigned char * bitcode, - unsigned bitcode_len); -unsigned radeon_llvm_get_num_kernels(const unsigned char *bitcode, unsigned bitcode_len); -LLVMModuleRef radeon_llvm_get_kernel_module(unsigned index, +LLVMModuleRef radeon_llvm_parse_bitcode(LLVMContextRef ctx, + const unsigned char * bitcode, unsigned bitcode_len); +unsigned radeon_llvm_get_num_kernels(LLVMContextRef ctx, + const unsigned char *bitcode, unsigned bitcode_len); +LLVMModuleRef radeon_llvm_get_kernel_module(LLVMContextRef ctx, unsigned index, const unsigned char *bitcode, unsigned bitcode_len); #endif |