diff options
author | Tom Stellard <[email protected]> | 2013-03-07 16:51:12 -0500 |
---|---|---|
committer | Tom Stellard <[email protected]> | 2013-03-13 16:01:31 +0000 |
commit | 3958c104c63d6675fd3e938ddff6efcfb1d67cde (patch) | |
tree | 92e1d9c51174adce2a7a59af5c4f74c64300f73b /src/gallium/drivers/radeon | |
parent | 2ace79dce5b6df453a903eb1ab51b688e0c00dd6 (diff) |
radeon/llvm: Optimize radeon_llvm_strip_unused_kernels()
Just delete unused kernels rather than marking them as internal and
running the GlobalDCE pass.
Also implement this function in C and inline it into
radeon_llvm_get_kernel_module()
Diffstat (limited to 'src/gallium/drivers/radeon')
-rw-r--r-- | src/gallium/drivers/radeon/radeon_llvm_util.cpp | 26 | ||||
-rw-r--r-- | src/gallium/drivers/radeon/radeon_llvm_util.h | 1 |
2 files changed, 10 insertions, 17 deletions
diff --git a/src/gallium/drivers/radeon/radeon_llvm_util.cpp b/src/gallium/drivers/radeon/radeon_llvm_util.cpp index 17a31228087..aa9f3b3c74c 100644 --- a/src/gallium/drivers/radeon/radeon_llvm_util.cpp +++ b/src/gallium/drivers/radeon/radeon_llvm_util.cpp @@ -29,17 +29,6 @@ static LLVMModuleRef radeon_llvm_parse_bitcode(const unsigned char * bitcode, return module; } -extern "C" void radeon_llvm_strip_unused_kernels(LLVMModuleRef mod, const char *kernel_name) -{ - llvm::Module *M = llvm::unwrap(mod); - std::vector<const char *> export_list; - export_list.push_back(kernel_name); - llvm::PassManager PM; - PM.add(llvm::createInternalizePass(export_list)); - PM.add(llvm::createGlobalDCEPass()); - PM.run(*M); -} - extern "C" unsigned radeon_llvm_get_num_kernels(const unsigned char *bitcode, unsigned bitcode_len) { @@ -53,16 +42,21 @@ extern "C" LLVMModuleRef radeon_llvm_get_kernel_module(unsigned index, LLVMModuleRef mod; unsigned num_kernels; LLVMValueRef *kernel_metadata; - LLVMValueRef kernel_signature, kernel_function; + unsigned i; mod = radeon_llvm_parse_bitcode(bitcode, bitcode_len); num_kernels = LLVMGetNamedMetadataNumOperands(mod, "opencl.kernels"); kernel_metadata = (LLVMValueRef*)MALLOC(num_kernels * sizeof(LLVMValueRef)); LLVMGetNamedMetadataOperands(mod, "opencl.kernels", kernel_metadata); - kernel_signature = kernel_metadata[index]; - LLVMGetMDNodeOperands(kernel_signature, &kernel_function); - const char* kernel_name = LLVMGetValueName(kernel_function); - radeon_llvm_strip_unused_kernels(mod, kernel_name); + for (i = 0; i < num_kernels; i++) { + LLVMValueRef kernel_signature, kernel_function; + if (i == index) { + continue; + } + kernel_signature = kernel_metadata[i]; + LLVMGetMDNodeOperands(kernel_signature, &kernel_function); + LLVMDeleteFunction(kernel_function); + } FREE(kernel_metadata); return mod; } diff --git a/src/gallium/drivers/radeon/radeon_llvm_util.h b/src/gallium/drivers/radeon/radeon_llvm_util.h index e144164b759..1e827ba0d7c 100644 --- a/src/gallium/drivers/radeon/radeon_llvm_util.h +++ b/src/gallium/drivers/radeon/radeon_llvm_util.h @@ -7,7 +7,6 @@ extern "C" { #endif -void radeon_llvm_strip_unused_kernels(LLVMModuleRef mod, const char *kernel_name); unsigned radeon_llvm_get_num_kernels(const unsigned char *bitcode, unsigned bitcode_len); LLVMModuleRef radeon_llvm_get_kernel_module(unsigned index, const unsigned char *bitcode, unsigned bitcode_len); |