From cf447c5da10952fd70bf8ca1eee12c72ecf0e219 Mon Sep 17 00:00:00 2001 From: Konstantin Seurer Date: Wed, 28 Aug 2024 09:48:15 +0200 Subject: [PATCH] nir: Do not gather source locations for phis MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Phi instructions are expected to be the first instructions in a block. Reviewed-by: Timur Kristóf Part-of: --- src/compiler/nir/nir_print.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c index 08eef87b913..b1953994ce0 100644 --- a/src/compiler/nir/nir_print.c +++ b/src/compiler/nir/nir_print.c @@ -2014,7 +2014,8 @@ print_instr(const nir_instr *instr, print_state *state, unsigned tabs) if (state->debug_info) { nir_debug_info_instr *di = state->debug_info[instr->index]; - di->src_loc.column = (uint32_t)ftell(fp); + if (di) + di->src_loc.column = (uint32_t)ftell(fp); } print_indentation(tabs, fp); @@ -2856,7 +2857,8 @@ nir_shader_gather_debug_info(nir_shader *shader, const char *filename, uint32_t nir_foreach_block(block, impl) { nir_foreach_instr_safe(instr, block) { - if (instr->type == nir_instr_type_debug_info) + if (instr->type == nir_instr_type_debug_info || + instr->type == nir_instr_type_phi) continue; nir_debug_info_instr *di = nir_debug_info_instr_create(shader, nir_debug_info_src_loc, 0); @@ -2874,6 +2876,8 @@ nir_shader_gather_debug_info(nir_shader *shader, const char *filename, uint32_t for (uint32_t i = 0; i < instr_count; i++) { nir_debug_info_instr *di = debug_info[i]; + if (!di) + continue; while (character_index < di->src_loc.column) { if (str[character_index] == '\n') @@ -2889,7 +2893,8 @@ nir_shader_gather_debug_info(nir_shader *shader, const char *filename, uint32_t nir_foreach_function_impl(impl, shader) { nir_foreach_block(block, impl) { nir_foreach_instr_safe(instr, block) { - if (instr->type != nir_instr_type_debug_info) + if (instr->type != nir_instr_type_debug_info && + instr->type != nir_instr_type_phi) nir_instr_insert_before(instr, &debug_info[instr_count++]->instr); } }