glsl: make an explicitly safe version of visit_exec_list()

visit_exec_list() has always called foreach_in_list_safe() here
were rename that version to visit_exec_list_safe() and create
a version that calls the non-safe foreach call.

There are only 2 users of visit_exec_list() we change lower_jumps
to use the renamed version and leave glsl_to_nir() to use the
non-safe version as it never deletes the current instruction and
in the following patch we will add code that may delete the next
instruction meaning the safe version would be unsafe to use.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27288>
This commit is contained in:
Timothy Arceri 2024-01-26 15:24:39 +11:00 committed by Marge Bot
parent 626502d7c7
commit f06aed8e1d
3 changed files with 12 additions and 1 deletions

View file

@ -2221,6 +2221,14 @@ ir_rvalue::error_value(void *mem_ctx)
void
visit_exec_list(exec_list *list, ir_visitor *visitor)
{
foreach_in_list(ir_instruction, node, list) {
node->accept(visitor);
}
}
void
visit_exec_list_safe(exec_list *list, ir_visitor *visitor)
{
foreach_in_list_safe(ir_instruction, node, list) {
node->accept(visitor);

View file

@ -2427,6 +2427,9 @@ public:
void
visit_exec_list(exec_list *list, ir_visitor *visitor);
void
visit_exec_list_safe(exec_list *list, ir_visitor *visitor);
/**
* Validate invariants on each IR node in a list
*/

View file

@ -929,7 +929,7 @@ do_lower_jumps(exec_list *instructions, bool pull_out_jumps, bool lower_sub_retu
bool progress_ever = false;
do {
v.progress = false;
visit_exec_list(instructions, &v);
visit_exec_list_safe(instructions, &v);
progress_ever = v.progress || progress_ever;
} while (v.progress);