From bfca15e16ae537d3ef9b1abfe232bf4b6c95c4c3 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Thu, 14 Jun 2018 14:28:58 +0200 Subject: [PATCH] radv: add RADV_DEBUG=checkir This allows to run the LLVM verifier pass. Signed-off-by: Samuel Pitoiset Reviewed-by: Bas Nieuwenhuizen --- src/amd/vulkan/radv_debug.h | 1 + src/amd/vulkan/radv_device.c | 1 + src/amd/vulkan/radv_nir_to_llvm.c | 10 +++++++--- src/amd/vulkan/radv_shader.c | 1 + src/amd/vulkan/radv_shader.h | 1 + 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/amd/vulkan/radv_debug.h b/src/amd/vulkan/radv_debug.h index 762b3382194..1e71349509e 100644 --- a/src/amd/vulkan/radv_debug.h +++ b/src/amd/vulkan/radv_debug.h @@ -48,6 +48,7 @@ enum { RADV_DEBUG_INFO = 0x40000, RADV_DEBUG_ERRORS = 0x80000, RADV_DEBUG_STARTUP = 0x100000, + RADV_DEBUG_CHECKIR = 0x200000, }; enum { diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index 5936b43093e..1ffbe75ef6b 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -410,6 +410,7 @@ static const struct debug_control radv_debug_options[] = { {"info", RADV_DEBUG_INFO}, {"errors", RADV_DEBUG_ERRORS}, {"startup", RADV_DEBUG_STARTUP}, + {"checkir", RADV_DEBUG_CHECKIR}, {NULL, 0} }; diff --git a/src/amd/vulkan/radv_nir_to_llvm.c b/src/amd/vulkan/radv_nir_to_llvm.c index a56f017e25c..5168c9d554a 100644 --- a/src/amd/vulkan/radv_nir_to_llvm.c +++ b/src/amd/vulkan/radv_nir_to_llvm.c @@ -2967,13 +2967,17 @@ handle_shader_outputs_post(struct ac_shader_abi *abi, unsigned max_outputs, } } -static void ac_llvm_finalize_module(struct radv_shader_context *ctx) +static void ac_llvm_finalize_module(struct radv_shader_context *ctx, + const struct radv_nir_compiler_options *options) { LLVMPassManagerRef passmgr; /* Create the pass manager */ passmgr = LLVMCreateFunctionPassManagerForModule( ctx->ac.module); + if (options->check_ir) + LLVMAddVerifierPass(passmgr); + /* This pass should eliminate all the load and store instructions */ LLVMAddPromoteMemoryToRegisterPass(passmgr); @@ -3299,7 +3303,7 @@ LLVMModuleRef ac_translate_nir_to_llvm(LLVMTargetMachineRef tm, if (options->dump_preoptir) ac_dump_module(ctx.ac.module); - ac_llvm_finalize_module(&ctx); + ac_llvm_finalize_module(&ctx, options); if (shader_count == 1) ac_nir_eliminate_const_vs_outputs(&ctx); @@ -3617,7 +3621,7 @@ radv_compile_gs_copy_shader(LLVMTargetMachineRef tm, LLVMBuildRetVoid(ctx.ac.builder); - ac_llvm_finalize_module(&ctx); + ac_llvm_finalize_module(&ctx, options); ac_compile_llvm_module(tm, ctx.ac.module, binary, config, shader_info, MESA_SHADER_VERTEX, options); diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c index 76790a19047..a68e1d02545 100644 --- a/src/amd/vulkan/radv_shader.c +++ b/src/amd/vulkan/radv_shader.c @@ -571,6 +571,7 @@ shader_variant_create(struct radv_device *device, options->dump_preoptir = options->dump_shader && device->instance->debug_flags & RADV_DEBUG_PREOPTIR; options->record_llvm_ir = device->keep_shader_info; + options->check_ir = device->instance->debug_flags & RADV_DEBUG_CHECKIR; options->tess_offchip_block_dw_size = device->tess_offchip_block_dw_size; options->address32_hi = device->physical_device->rad_info.address32_hi; diff --git a/src/amd/vulkan/radv_shader.h b/src/amd/vulkan/radv_shader.h index 5b2284efcfd..e95bbfca894 100644 --- a/src/amd/vulkan/radv_shader.h +++ b/src/amd/vulkan/radv_shader.h @@ -119,6 +119,7 @@ struct radv_nir_compiler_options { bool dump_shader; bool dump_preoptir; bool record_llvm_ir; + bool check_ir; enum radeon_family family; enum chip_class chip_class; uint32_t tess_offchip_block_dw_size; -- 2.30.2