From: Dave Airlie <airl...@redhat.com> This is prep work for moving this to a per-thread struct --- src/amd/vulkan/radv_nir_to_llvm.c | 15 +++++++-------- src/amd/vulkan/radv_private.h | 2 ++ src/amd/vulkan/radv_shader.c | 7 +++++-- 3 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/src/amd/vulkan/radv_nir_to_llvm.c b/src/amd/vulkan/radv_nir_to_llvm.c index 1c9f58c6bcf..ea055881084 100644 --- a/src/amd/vulkan/radv_nir_to_llvm.c +++ b/src/amd/vulkan/radv_nir_to_llvm.c @@ -2993,15 +2993,11 @@ handle_shader_outputs_post(struct ac_shader_abi *abi, unsigned max_outputs, } static void ac_llvm_finalize_module(struct radv_shader_context *ctx, + LLVMPassManagerRef passmgr, const struct radv_nir_compiler_options *options) { - LLVMPassManagerRef passmgr; - - passmgr = ac_init_passmgr(NULL, options->check_ir); - LLVMRunPassManager(passmgr, ctx->ac.module); LLVMDisposeBuilder(ctx->ac.builder); - LLVMDisposePassManager(passmgr); ac_llvm_context_dispose(&ctx->ac); } @@ -3132,6 +3128,7 @@ static void prepare_gs_input_vgprs(struct radv_shader_context *ctx) static LLVMModuleRef ac_translate_nir_to_llvm(LLVMTargetMachineRef tm, + LLVMPassManagerRef passmgr, struct nir_shader *const *shaders, int shader_count, struct radv_shader_variant_info *shader_info, @@ -3307,7 +3304,7 @@ LLVMModuleRef ac_translate_nir_to_llvm(LLVMTargetMachineRef tm, if (options->dump_preoptir) ac_dump_module(ctx.ac.module); - ac_llvm_finalize_module(&ctx, options); + ac_llvm_finalize_module(&ctx, passmgr, options); if (shader_count == 1) ac_nir_eliminate_const_vs_outputs(&ctx); @@ -3508,6 +3505,7 @@ ac_fill_shader_info(struct radv_shader_variant_info *shader_info, struct nir_sha void radv_compile_nir_shader(LLVMTargetMachineRef tm, + LLVMPassManagerRef passmgr, struct ac_shader_binary *binary, struct ac_shader_config *config, struct radv_shader_variant_info *shader_info, @@ -3518,7 +3516,7 @@ radv_compile_nir_shader(LLVMTargetMachineRef tm, LLVMModuleRef llvm_module; - llvm_module = ac_translate_nir_to_llvm(tm, nir, nir_count, shader_info, + llvm_module = ac_translate_nir_to_llvm(tm, passmgr, nir, nir_count, shader_info, options); ac_compile_llvm_module(tm, llvm_module, binary, config, shader_info, @@ -3580,6 +3578,7 @@ ac_gs_copy_shader_emit(struct radv_shader_context *ctx) void radv_compile_gs_copy_shader(LLVMTargetMachineRef tm, + LLVMPassManagerRef passmgr, struct nir_shader *geom_shader, struct ac_shader_binary *binary, struct ac_shader_config *config, @@ -3625,7 +3624,7 @@ radv_compile_gs_copy_shader(LLVMTargetMachineRef tm, LLVMBuildRetVoid(ctx.ac.builder); - ac_llvm_finalize_module(&ctx, options); + ac_llvm_finalize_module(&ctx, passmgr, options); ac_compile_llvm_module(tm, ctx.ac.module, binary, config, shader_info, MESA_SHADER_VERTEX, options); diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h index a202697e935..7f741480ac3 100644 --- a/src/amd/vulkan/radv_private.h +++ b/src/amd/vulkan/radv_private.h @@ -1798,6 +1798,7 @@ struct radv_shader_variant_info; struct radv_nir_compiler_options; void radv_compile_gs_copy_shader(LLVMTargetMachineRef tm, + LLVMPassManagerRef passmgr, struct nir_shader *geom_shader, struct ac_shader_binary *binary, struct ac_shader_config *config, @@ -1805,6 +1806,7 @@ void radv_compile_gs_copy_shader(LLVMTargetMachineRef tm, const struct radv_nir_compiler_options *option); void radv_compile_nir_shader(LLVMTargetMachineRef tm, + LLVMPassManagerRef passmgr, struct ac_shader_binary *binary, struct ac_shader_config *config, struct radv_shader_variant_info *shader_info, diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c index 2d012d41fea..b694300b777 100644 --- a/src/amd/vulkan/radv_shader.c +++ b/src/amd/vulkan/radv_shader.c @@ -526,6 +526,7 @@ shader_variant_create(struct radv_device *device, struct radv_shader_variant *variant; struct ac_shader_binary binary; LLVMTargetMachineRef tm; + LLVMPassManagerRef passmgr; variant = calloc(1, sizeof(struct radv_shader_variant)); if (!variant) @@ -548,17 +549,19 @@ shader_variant_create(struct radv_device *device, radv_init_llvm_once(); tm = ac_create_target_machine(chip_family, tm_options, NULL); + passmgr = ac_init_passmgr(NULL, options->check_ir); if (gs_copy_shader) { assert(shader_count == 1); - radv_compile_gs_copy_shader(tm, *shaders, &binary, + radv_compile_gs_copy_shader(tm, passmgr, *shaders, &binary, &variant->config, &variant->info, options); } else { - radv_compile_nir_shader(tm, &binary, &variant->config, + radv_compile_nir_shader(tm, passmgr, &binary, &variant->config, &variant->info, shaders, shader_count, options); } + LLVMDisposePassManager(passmgr); LLVMDisposeTargetMachine(tm); radv_fill_shader_variant(device, variant, &binary, stage); -- 2.17.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev