nir: Use nir_src_copy instead of direct assignments.
authorKenneth Graunke <kenneth@whitecape.org>
Tue, 18 Jul 2017 04:08:42 +0000 (21:08 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Wed, 19 Jul 2017 06:44:50 +0000 (23:44 -0700)
commit0320bb2c6cb27370e2389b392b63f8d05c7cb4c7
treea4ee5f988516b5f1b31c36506911a75a1b4eb0df
parent57165f2ef8ea743238ac1074fe80539a91da4835
nir: Use nir_src_copy instead of direct assignments.

If the source is an indirect register, there is ralloc'd data.  Copying
with a direct assignment will copy the pointer, but the data will still
belong to the old instruction's memory context.  Since we're lowering
and throwing away instructions, that could free the data by mistake.

Instead, use nir_src_copy, which properly handles this.

This is admittedly not a common case, so I think the bug is real,
but unlikely to be hit.

Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/compiler/nir/nir_lower_atomics.c
src/compiler/nir/nir_lower_atomics_to_ssbo.c
src/compiler/nir/nir_lower_io_to_scalar.c