intel/brw: Add assert for error case
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

Coverity notices that there is an error case where
`nir_get_io_data_src_number` could return `-1`, and that is then used to
index into an array. Given that that is an exceptional case, we can just
assert here.

CID: 1681480
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40146>
This commit is contained in:
Dylan Baker 2026-02-27 09:03:26 -08:00 committed by Marge Bot
parent 825df24023
commit 4381ac9a91

View file

@ -17,6 +17,7 @@
#include "util/lut.h"
#include "compiler/glsl_types.h"
#include <cassert>
#include <optional>
struct brw_bind_info {
@ -6002,8 +6003,14 @@ brw_from_nir_emit_memory_access(nir_to_brw_state &ntb,
}
int data_src = nir_get_io_data_src_number(instr);
unsigned components = is_store ? instr->src[data_src].ssa->num_components
: instr->def.num_components;
unsigned components;
if (is_store) {
assert(data_src >= 0);
components = instr->src[data_src].ssa->num_components;
} else {
components = instr->def.num_components;
}
if (components == 0)
components = instr->num_components;