broadcom/compiler: fix dynamic-stack-buffer-overflow error
authorJuan A. Suarez Romero <jasuarez@igalia.com>
Fri, 30 Apr 2021 16:44:02 +0000 (18:44 +0200)
committerMarge Bot <eric+marge@anholt.net>
Tue, 11 May 2021 07:46:17 +0000 (07:46 +0000)
commit54ec9c95cff7d98221b361c49ee2d43a4c149e88
treef7593b563d6401838f388bda6298bbff23ee53bb
parentcf030ceef3f6eaa1b8752207393b50679b2ca857
broadcom/compiler: fix dynamic-stack-buffer-overflow error

When spilling a register, the number of temps can be increased when
introducing a temporal variable.

Those nodes are not elegible to be spilled, but we need to take care of
no accessing out-of-bounds of the arrays defined with a size equal to
the original number of temps.

Fixes address sanitizer error on
KHR-GLES3.shaders.uniform_block.random.all_shared_buffer.14 (and many
others).

v2 (Iago):
 - Add clarification in assertion.
 - Use `vir_get_temp` to increase num_temps.

v3 (Iago):
 - Update clarification

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10643>
src/broadcom/compiler/vir_register_allocate.c