radeon/llvm: Specify the DataLayout when running optimizations
authorTom Stellard <thomas.stellard@amd.com>
Tue, 22 Oct 2013 16:26:12 +0000 (09:26 -0700)
committerTom Stellard <thomas.stellard@amd.com>
Wed, 30 Oct 2013 23:40:06 +0000 (16:40 -0700)
Without DataLayout, a lot of optimization passes aren't run and the ones
that are don't work as well.

src/gallium/drivers/radeon/radeon_llvm_util.c

index 25be2459366b25ef63c6e8a8026f1c9569aa9ce4..7192dee9732a6f711846a0fbd3d3bca1c2cf7e54 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <llvm-c/BitReader.h>
 #include <llvm-c/Core.h>
+#include <llvm-c/Target.h>
 #include <llvm-c/Transforms/PassManagerBuilder.h>
 
 LLVMModuleRef radeon_llvm_parse_bitcode(const unsigned char * bitcode,
@@ -53,8 +54,11 @@ unsigned radeon_llvm_get_num_kernels(const unsigned char *bitcode,
 
 static void radeon_llvm_optimize(LLVMModuleRef mod)
 {
+       const char *data_layout = LLVMGetDataLayout(mod);
+       LLVMTargetDataRef TD = LLVMCreateTargetData(data_layout);
        LLVMPassManagerBuilderRef builder = LLVMPassManagerBuilderCreate();
        LLVMPassManagerRef pass_manager = LLVMCreatePassManager();
+       LLVMAddTargetData(TD, pass_manager);
 
        LLVMPassManagerBuilderUseInlinerWithThreshold(builder, 1000000000);
        LLVMPassManagerBuilderPopulateModulePassManager(builder, pass_manager);