glsl: Make sure that the variable is a ir_variable before unreferencing it

While it technically was already only using an ir_instruction field, better make
sure that it is effectively an ir_variable using the dedicated method instead of
relying on an undefined behavior.

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>

Signed-off-by: Corentin Noël <corentin.noel@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26144>
This commit is contained in:
Corentin Noël 2023-11-10 18:35:22 +01:00 committed by Marge Bot
parent d9c4ccf56d
commit 68f5277887

View file

@ -36,8 +36,9 @@ void
optimize_dead_builtin_variables(exec_list *instructions,
enum ir_variable_mode other)
{
foreach_in_list_safe(ir_variable, var, instructions) {
if (var->ir_type != ir_type_variable || var->data.used)
foreach_in_list_safe(ir_instruction, inst, instructions) {
ir_variable *var = inst->as_variable();
if (!var || var->data.used)
continue;
if (var->data.mode != ir_var_uniform