pco: Fix encoding of branch to an empty block
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

When calculating the relative offset for a branch the pco_first_igrp
function is used to find the first instruction of a block.

However if the block is empty the function does not return NULL as it
description implies but returns a pointer to the list head which is not a
valid node. Using this leads to a garbage relative offset been calculated
which leads to unexpected behaviour.

Fix is to add a check for the list been empty and return NULL (the same
issue also exists in pco_last_igrp). This leads to the calling function,
pco_cf_node_offset, searching for the next none empty block which is the
expected behaviour.

Fix deqp:
dEQP-VK.graphicsfuzz.cov-two-nested-loops-switch-case-matrix-array-increment
dEQP-VK.graphicsfuzz.stable-binarysearch-tree-false-if-discard-loop

Signed-off-by: Nick Hamilton <nick.hamilton@imgtec.com>
Reviewed-by: Simon Perretta <simon.perretta@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39287>
This commit is contained in:
Nick Hamilton 2026-01-09 10:27:01 +00:00 committed by Marge Bot
parent 371656de90
commit 68cb76de5d

View file

@ -1534,6 +1534,9 @@ static inline pco_instr *pco_prev_instr(pco_instr *instr)
*/
static inline pco_igrp *pco_first_igrp(pco_block *block)
{
if (list_is_empty(&block->instrs))
return NULL;
return list_first_entry(&block->instrs, pco_igrp, link);
}
@ -1545,6 +1548,9 @@ static inline pco_igrp *pco_first_igrp(pco_block *block)
*/
static inline pco_igrp *pco_last_igrp(pco_block *block)
{
if (list_is_empty(&block->instrs))
return NULL;
return list_first_entry(&block->instrs, pco_igrp, link);
}