diff options
author | Tom Stellard <[email protected]> | 2013-05-14 08:56:25 -0700 |
---|---|---|
committer | Tom Stellard <[email protected]> | 2013-05-17 07:38:01 -0700 |
commit | e230d9debbd4c2e715f50059a02d502d90a626d7 (patch) | |
tree | 40c9e0613cf056a30411063d781192875b514bbf /src | |
parent | ccb041fe8e0f4ed7e393bb82e89a7c57d222bec7 (diff) |
radeon/llvm: Run standard optimization passes on conpute shader modules
The SROA and function inliner passes are espically important, because
they optimize away unsupported features: functions and indirect
private memory access.
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/radeon/radeon_llvm_util.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/gallium/drivers/radeon/radeon_llvm_util.c b/src/gallium/drivers/radeon/radeon_llvm_util.c index e3b0d638b71..25be2459366 100644 --- a/src/gallium/drivers/radeon/radeon_llvm_util.c +++ b/src/gallium/drivers/radeon/radeon_llvm_util.c @@ -29,6 +29,7 @@ #include <llvm-c/BitReader.h> #include <llvm-c/Core.h> +#include <llvm-c/Transforms/PassManagerBuilder.h> LLVMModuleRef radeon_llvm_parse_bitcode(const unsigned char * bitcode, unsigned bitcode_len) @@ -50,6 +51,19 @@ unsigned radeon_llvm_get_num_kernels(const unsigned char *bitcode, return LLVMGetNamedMetadataNumOperands(mod, "opencl.kernels"); } +static void radeon_llvm_optimize(LLVMModuleRef mod) +{ + LLVMPassManagerBuilderRef builder = LLVMPassManagerBuilderCreate(); + LLVMPassManagerRef pass_manager = LLVMCreatePassManager(); + + LLVMPassManagerBuilderUseInlinerWithThreshold(builder, 1000000000); + LLVMPassManagerBuilderPopulateModulePassManager(builder, pass_manager); + + LLVMRunPassManager(pass_manager, mod); + LLVMPassManagerBuilderDispose(builder); + LLVMDisposePassManager(pass_manager); +} + LLVMModuleRef radeon_llvm_get_kernel_module(unsigned index, const unsigned char *bitcode, unsigned bitcode_len) { @@ -72,5 +86,6 @@ LLVMModuleRef radeon_llvm_get_kernel_module(unsigned index, LLVMDeleteFunction(kernel_function); } FREE(kernel_metadata); + radeon_llvm_optimize(mod); return mod; } |