From 495812d8e027bb7bf4ded5dfd893bed1d57abe54 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 25 Feb 2025 16:51:22 -0800 Subject: [PATCH] brw/print: Don't let SHADER_OPCODE_FLOW affect indentation In `fossilize-replay --pipeline-hash 375a63e14afa96c4 fossils/fossil-db/steam-dxvk/f1_22_abu_dhabi.dx12vk-ultra.foz`, `cf_count` would get decremented below zero. This would lead trying to print `UINT_MAX` levels of indentation just a few lines below. I ran out of disk space and patience before that finished. :rofl: Reviewed-by: Caio Oliveira Part-of: --- src/intel/compiler/brw_print.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/intel/compiler/brw_print.cpp b/src/intel/compiler/brw_print.cpp index d19b4fe479e..6467c370cd5 100644 --- a/src/intel/compiler/brw_print.cpp +++ b/src/intel/compiler/brw_print.cpp @@ -30,8 +30,14 @@ brw_print_instructions(const brw_shader &s, FILE *file) fprintf(file, "\n"); foreach_inst_in_block(brw_inst, inst, block) { - if (inst->is_control_flow_end()) + /* SHADER_OPCODE_FLOW ends a block, but it does not change the + * control flow nested (i.e., the indentation). + */ + if (inst->is_control_flow_end() && inst->opcode != SHADER_OPCODE_FLOW) { + /* If cf_count is 0 and decremented, bad things will happen. */ + assert(cf_count > 0); cf_count -= 1; + } if (rp) { max_pressure = MAX2(max_pressure, rp->regs_live_at_ip[ip]);