broadcom/compiler: change current block on setting spill base

The spill base setting instructions (which includes some uniforms) are
added in the entry block, not in the current block. When ldunif
optimization is applied, the cursor is pointing to instructions in the
entry block, but the current block is a different one. This leads to a
heap-buffer-overflow when going through the list of instructions
(detected by the address sanitizer).

Thus change the current block to entry block, and restore it after the
setup is done.

This fixes
dEQP-VK.ssbo.readonly.layout.single_struct.single_buffer.std430_instance_array_comp_access_store_cols
with address sanitizer enabled.

v2:
 - Set current block instead of disabling ldunif optimization (Iago)

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/12221>
This commit is contained in:
Juan A. Suarez Romero
2021-08-09 11:40:55 +02:00
committed by Marge Bot
parent 90ee96992c
commit d0e83b6174

View File

@@ -177,7 +177,12 @@ v3d_choose_spill_node(struct v3d_compile *c, struct ra_graph *g,
void
v3d_setup_spill_base(struct v3d_compile *c)
{
c->cursor = vir_before_block(vir_entry_block(c));
/* Setting up the spill base is done in the entry block; so change
* both the current block to emit and the cursor.
*/
struct qblock *current_block = c->cur_block;
c->cur_block = vir_entry_block(c);
c->cursor = vir_before_block(c->cur_block);
int start_num_temps = c->num_temps;
@@ -204,6 +209,8 @@ v3d_setup_spill_base(struct v3d_compile *c)
for (int i = start_num_temps; i < c->num_temps; i++)
BITSET_CLEAR(c->spillable, i);
/* Restore the current block. */
c->cur_block = current_block;
c->cursor = vir_after_block(c->cur_block);
}