Module: Mesa Branch: main Commit: d9c4ccf56dd0d963f5e844776e1ea4bc75ec94b5 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d9c4ccf56dd0d963f5e844776e1ea4bc75ec94b5
Author: Corentin Noël <corentin.n...@collabora.com> Date: Fri Nov 10 12:42:43 2023 +0100 glsl: Make sure to not cast ir_dereference_variable into ir_variable The parameter_lists_match_exact function was wrongly assuming that all the elements were ir_variable when there can also be ir_dereference_variable elements. Add case taking this into account. Reviewed-by: Erik Faye-Lund <erik.faye-l...@collabora.com> Signed-off-by: Corentin Noël <corentin.n...@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26144> --- src/compiler/glsl/ir_function.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/compiler/glsl/ir_function.cpp b/src/compiler/glsl/ir_function.cpp index 82987522d66..9e75958eb76 100644 --- a/src/compiler/glsl/ir_function.cpp +++ b/src/compiler/glsl/ir_function.cpp @@ -370,6 +370,18 @@ ir_function::matching_signature(_mesa_glsl_parse_state *state, } +static inline const glsl_type * +get_param_type(ir_instruction *inst) +{ + ir_variable *var = inst->as_variable(); + if (var) + return var->type; + + ir_rvalue *rvalue = inst->as_rvalue(); + assert(rvalue != NULL); + return rvalue->type; +} + static bool parameter_lists_match_exact(const exec_list *list_a, const exec_list *list_b) { @@ -379,13 +391,13 @@ parameter_lists_match_exact(const exec_list *list_a, const exec_list *list_b) for (/* empty */ ; !node_a->is_tail_sentinel() && !node_b->is_tail_sentinel() ; node_a = node_a->next, node_b = node_b->next) { - ir_variable *a = (ir_variable *) node_a; - ir_variable *b = (ir_variable *) node_b; + ir_instruction *inst_a = (ir_instruction *) node_a; + ir_instruction *inst_b = (ir_instruction *) node_b; /* If the types of the parameters do not match, the parameters lists * are different. */ - if (a->type != b->type) + if (get_param_type (inst_a) != get_param_type (inst_b)) return false; }