radv: add an option that allows to dump pre-optimization ir
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 19 Jan 2018 11:12:02 +0000 (12:12 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 22 Jan 2018 11:28:33 +0000 (12:28 +0100)
With RADV_DEBUG=preoptir.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/amd/common/ac_nir_to_llvm.c
src/amd/common/ac_nir_to_llvm.h
src/amd/vulkan/radv_debug.h
src/amd/vulkan/radv_device.c
src/amd/vulkan/radv_shader.c

index 2aef51be85500c32b04e4d54da9be7bfe5a8ffbe..3d9cb249ad69d0ec64229702532dca3590616151 100644 (file)
@@ -6848,6 +6848,9 @@ LLVMModuleRef ac_translate_nir_to_llvm(LLVMTargetMachineRef tm,
 
        LLVMBuildRetVoid(ctx.builder);
 
+       if (options->dump_preoptir)
+               ac_dump_module(ctx.module);
+
        ac_llvm_finalize_module(&ctx);
 
        if (shader_count == 1)
index 1737866166ea7e0d23a5000afc0132f08553ca10..62ea38be373bfc75ffd8a08df54f52a34032df7b 100644 (file)
@@ -81,6 +81,7 @@ struct ac_nir_compiler_options {
        bool unsafe_math;
        bool supports_spill;
        bool clamp_shadow_reference;
+       bool dump_preoptir;
        enum radeon_family family;
        enum chip_class chip_class;
 };
index 5b37bfe0847d87f6a23fca2cc6cded3ef96bbf35..804f620690db1d24f82312c68b62bcb3d8dbd2c6 100644 (file)
@@ -42,6 +42,7 @@ enum {
        RADV_DEBUG_ZERO_VRAM         = 0x1000,
        RADV_DEBUG_SYNC_SHADERS      = 0x2000,
        RADV_DEBUG_NO_SISCHED        = 0x4000,
+       RADV_DEBUG_PREOPTIR          = 0x8000,
 };
 
 enum {
index b5ae103239278c628379e85596ba5fd3901a1e21..4463e6945ef589216f6a00d956771554559a967a 100644 (file)
@@ -336,6 +336,7 @@ static const struct debug_control radv_debug_options[] = {
        {"zerovram", RADV_DEBUG_ZERO_VRAM},
        {"syncshaders", RADV_DEBUG_SYNC_SHADERS},
        {"nosisched", RADV_DEBUG_NO_SISCHED},
+       {"preoptir", RADV_DEBUG_PREOPTIR},
        {NULL, 0}
 };
 
index 3bcaac168adf09f52873af10880d15d79b7f8867..620effe50e6b4e9bc918e2a3c7aeafb5802f7568 100644 (file)
@@ -476,6 +476,8 @@ shader_variant_create(struct radv_device *device,
 
        options->family = chip_family;
        options->chip_class = device->physical_device->rad_info.chip_class;
+       options->dump_preoptir = radv_can_dump_shader(device, module) &&
+                                device->instance->debug_flags & RADV_DEBUG_PREOPTIR;
 
        if (options->supports_spill)
                tm_options |= AC_TM_SUPPORTS_SPILL;