radeonsi: fold surrounding code into si_llvm_finalize_module
authorMarek Olšák <marek.olsak@amd.com>
Fri, 28 Apr 2017 18:23:19 +0000 (20:23 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 4 May 2017 22:23:44 +0000 (00:23 +0200)
and rename to si_llvm_optimize_module.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/radeonsi/si_shader.c
src/gallium/drivers/radeonsi/si_shader_internal.h
src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c

index 2928fc9039ccaba5e1d149d331ca1bff3aa23561..736084f1ad101bf5ca728e55f1b3fd940731a09b 100644 (file)
@@ -7015,13 +7015,8 @@ si_generate_gs_copy_shader(struct si_screen *sscreen,
 
        LLVMBuildRetVoid(gallivm->builder);
 
-       /* Dump LLVM IR before any optimization passes */
-       if (sscreen->b.debug_flags & DBG_PREOPT_IR &&
-           r600_can_dump_shader(&sscreen->b, PIPE_SHADER_GEOMETRY))
-               ac_dump_module(ctx.gallivm.module);
-
-       si_llvm_finalize_module(&ctx,
-               r600_extra_shader_checks(&sscreen->b, PIPE_SHADER_GEOMETRY));
+       ctx.type = PIPE_SHADER_GEOMETRY; /* override for shader dumping */
+       si_llvm_optimize_module(&ctx);
 
        r = si_compile_llvm(sscreen, &ctx.shader->binary,
                            &ctx.shader->config, ctx.tm,
@@ -8152,13 +8147,7 @@ int si_compile_tgsi_shader(struct si_screen *sscreen,
                                          need_prolog ? 1 : 0, 0);
        }
 
-       /* Dump LLVM IR before any optimization passes */
-       if (sscreen->b.debug_flags & DBG_PREOPT_IR &&
-           r600_can_dump_shader(&sscreen->b, ctx.type))
-               LLVMDumpModule(ctx.gallivm.module);
-
-       si_llvm_finalize_module(&ctx,
-                                   r600_extra_shader_checks(&sscreen->b, ctx.type));
+       si_llvm_optimize_module(&ctx);
 
        /* Post-optimization transformations and analysis. */
        si_eliminate_const_vs_outputs(&ctx);
@@ -8327,8 +8316,7 @@ si_get_shader_part(struct si_screen *sscreen,
        build(&ctx, key);
 
        /* Compile. */
-       si_llvm_finalize_module(&ctx,
-               r600_extra_shader_checks(&sscreen->b, PIPE_SHADER_FRAGMENT));
+       si_llvm_optimize_module(&ctx);
 
        if (si_compile_llvm(sscreen, &result->binary, &result->config, tm,
                            gallivm->module, debug, ctx.type, name)) {
index 03bf83d85acc1327026ef5c8aed4d4792f1ab020..b54db20c704de40d25519c97b1be47ab183d7d7c 100644 (file)
@@ -271,8 +271,7 @@ void si_llvm_create_func(struct si_shader_context *ctx,
 
 void si_llvm_dispose(struct si_shader_context *ctx);
 
-void si_llvm_finalize_module(struct si_shader_context *ctx,
-                            bool run_verifier);
+void si_llvm_optimize_module(struct si_shader_context *ctx);
 
 LLVMValueRef si_llvm_emit_fetch_64bit(struct lp_build_tgsi_context *bld_base,
                                      enum tgsi_opcode_type type,
index a2c7e67cf52169b9e7a4e006c9c681a964e09fc9..2b0d6001fd5c24ff13755b2bb170c002cea5682a 100644 (file)
@@ -1409,20 +1409,24 @@ void si_llvm_create_func(struct si_shader_context *ctx,
        LLVMPositionBuilderAtEnd(ctx->gallivm.builder, main_fn_body);
 }
 
-void si_llvm_finalize_module(struct si_shader_context *ctx,
-                            bool run_verifier)
+void si_llvm_optimize_module(struct si_shader_context *ctx)
 {
        struct gallivm_state *gallivm = &ctx->gallivm;
        const char *triple = LLVMGetTarget(gallivm->module);
        LLVMTargetLibraryInfoRef target_library_info;
 
+       /* Dump LLVM IR before any optimization passes */
+       if (ctx->screen->b.debug_flags & DBG_PREOPT_IR &&
+           r600_can_dump_shader(&ctx->screen->b, ctx->type))
+               LLVMDumpModule(ctx->gallivm.module);
+
        /* Create the pass manager */
        gallivm->passmgr = LLVMCreatePassManager();
 
        target_library_info = gallivm_create_target_library_info(triple);
        LLVMAddTargetLibraryInfo(target_library_info, gallivm->passmgr);
 
-       if (run_verifier)
+       if (r600_extra_shader_checks(&ctx->screen->b, ctx->type))
                LLVMAddVerifierPass(gallivm->passmgr);
 
        LLVMAddAlwaysInlinerPass(gallivm->passmgr);