gallium/radeon: emit LLVM `ret void` before radeon_llvm_finalize_module
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Thu, 4 Feb 2016 07:51:52 +0000 (08:51 +0100)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Fri, 5 Feb 2016 14:21:54 +0000 (09:21 -0500)
This allows dumping a consumable LLVM module before the initial optimization
passes are run.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/drivers/r600/r600_llvm.c
src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
src/gallium/drivers/radeonsi/si_shader.c

index 232db135be994c499b87bfe84d2fc13776fbd812..0fe7c74418d49d694223bfd472d4b6dcc120d5a6 100644 (file)
@@ -848,6 +848,7 @@ LLVMModuleRef r600_tgsi_llvm(
 
        lp_build_tgsi_llvm(bld_base, tokens);
 
+       LLVMBuildRetVoid(bld_base->base.gallivm->builder);
        radeon_llvm_finalize_module(ctx);
 
        return ctx->gallivm.module;
index d8e05cef448eca0cfddd07d8eecd512a77b17a00..f5e3f6af1a07cb9e3a5ab818560cbd85b556cd26 100644 (file)
@@ -1710,11 +1710,9 @@ void radeon_llvm_create_func(struct radeon_llvm_context * ctx,
 void radeon_llvm_finalize_module(struct radeon_llvm_context * ctx)
 {
        struct gallivm_state * gallivm = ctx->soa.bld_base.base.gallivm;
-       /* End the main function with Return*/
-       LLVMBuildRetVoid(gallivm->builder);
 
        /* Create the pass manager */
-       ctx->gallivm.passmgr = LLVMCreateFunctionPassManagerForModule(
+       gallivm->passmgr = LLVMCreateFunctionPassManagerForModule(
                                                        gallivm->module);
 
        /* This pass should eliminate all the load and store instructions */
index 2192b2120f28ac0b95ef2f3f906f40c655b66981..8b524cf4ada3b6060369aafb3ea46b71ad794b5d 100644 (file)
@@ -4177,6 +4177,7 @@ static int si_generate_gs_copy_shader(struct si_screen *sscreen,
 
        si_llvm_export_vs(bld_base, outputs, gsinfo->num_outputs);
 
+       LLVMBuildRetVoid(bld_base->base.gallivm->builder);
        radeon_llvm_finalize_module(&si_shader_ctx->radeon_bld);
 
        if (dump)
@@ -4383,6 +4384,7 @@ int si_shader_create(struct si_screen *sscreen, LLVMTargetMachineRef tm,
                goto out;
        }
 
+       LLVMBuildRetVoid(bld_base->base.gallivm->builder);
        radeon_llvm_finalize_module(&si_shader_ctx.radeon_bld);
 
        mod = bld_base->base.gallivm->module;