From dd1ca1588dc191991c1e3442d02d2110133370c6 Mon Sep 17 00:00:00 2001 From: Caio Oliveira Date: Tue, 11 Feb 2025 20:40:36 -0800 Subject: [PATCH] brw: Fix size in assembler when compacting Calculation was wrongly walking uncompacted instructions, even if we had some compacted in the middle, generating invalid size. Since we are here just drop the instruction count, since in practice the caller will have to walk the instruction stream anyway. Fixes: 6267585778f ("intel/brw: Also return the size of the assembled shader") Reviewed-by: Paulo Zanoni Part-of: --- src/intel/compiler/brw_asm.c | 17 +++-------------- src/intel/compiler/brw_asm.h | 1 - src/intel/compiler/brw_asm_tool.c | 3 +-- 3 files changed, 4 insertions(+), 17 deletions(-) diff --git a/src/intel/compiler/brw_asm.c b/src/intel/compiler/brw_asm.c index a7429f64544..2bbac833eb2 100644 --- a/src/intel/compiler/brw_asm.c +++ b/src/intel/compiler/brw_asm.c @@ -135,22 +135,11 @@ brw_assemble(void *mem_ctx, const struct intel_device_info *devinfo, goto end; } - result.bin = p->store; - result.bin_size = p->next_insn_offset; - result.inst_count = p->next_insn_offset / 16; - - if ((flags & BRW_ASSEMBLE_COMPACT) != 0) { + if ((flags & BRW_ASSEMBLE_COMPACT) != 0) brw_compact_instructions(p, 0, disasm_info); - /* Adjust bin size to account for compacted instructions. */ - int compacted = 0; - for (int i = 0; i < result.inst_count; i++) { - const brw_eu_inst *inst = result.bin + i; - if (brw_eu_inst_cmpt_control(devinfo, inst)) - compacted++; - } - result.bin_size -= compacted * 8; - } + result.bin = p->store; + result.bin_size = p->next_insn_offset; if ((flags & BRW_ASSEMBLE_DUMP) != 0) dump_assembly(p->store, 0, p->next_insn_offset, disasm_info, NULL); diff --git a/src/intel/compiler/brw_asm.h b/src/intel/compiler/brw_asm.h index d159d09bc71..078cd988845 100644 --- a/src/intel/compiler/brw_asm.h +++ b/src/intel/compiler/brw_asm.h @@ -13,7 +13,6 @@ struct intel_device_info; typedef struct { void *bin; int bin_size; - int inst_count; } brw_assemble_result; typedef enum { diff --git a/src/intel/compiler/brw_asm_tool.c b/src/intel/compiler/brw_asm_tool.c index 36e9e79e7d4..6b2f02c3244 100644 --- a/src/intel/compiler/brw_asm_tool.c +++ b/src/intel/compiler/brw_asm_tool.c @@ -136,7 +136,6 @@ int main(int argc, char **argv) FILE *output = stdout; bool help = false, compact = false; uint64_t pci_id = 0; - int offset = 0; struct intel_device_info *devinfo = NULL; int result = EXIT_FAILURE; @@ -237,7 +236,7 @@ int main(int argc, char **argv) if (output_type == OPT_OUTPUT_C_LITERAL) fprintf(output, "{\n"); - for (int i = 0; i < r.inst_count; i++) { + for (int offset = 0; offset < r.bin_size;) { const brw_eu_inst *insn = r.bin + offset; bool compacted = false;