diff options
author | Kenneth Graunke <kenneth@whitecape.org> | 2017-07-17 21:08:42 -0700 |
---|---|---|
committer | Emil Velikov <emil.l.velikov@gmail.com> | 2017-08-03 00:19:06 +0100 |
commit | 891d1f8fea7ef55745f7cc0009eec6023818ac31 (patch) | |
tree | ba489acb06279e5421763f30722fe81b187b645d | |
parent | ca17d32544f636db0fabc46ea0cdfe29bbc003fc (diff) |
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>
(cherry picked from commit 0320bb2c6cb27370e2389b392b63f8d05c7cb4c7)
[Emil Velikov: drop nir_lower_atomics_to_ssbo.c - not in branch]
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Conflicts:
src/compiler/nir/nir_lower_atomics_to_ssbo.c
-rw-r--r-- | src/compiler/nir/nir_lower_atomics.c | 2 | ||||
-rw-r--r-- | src/compiler/nir/nir_lower_io_to_scalar.c | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/compiler/nir/nir_lower_atomics.c b/src/compiler/nir/nir_lower_atomics.c index 1993013f8f6..2252e1679be 100644 --- a/src/compiler/nir/nir_lower_atomics.c +++ b/src/compiler/nir/nir_lower_atomics.c @@ -155,7 +155,7 @@ lower_instr(nir_intrinsic_instr *instr, * instruction. */ for (unsigned i = 0; i < nir_intrinsic_infos[instr->intrinsic].num_srcs; i++) - new_instr->src[i + 1] = instr->src[i]; + nir_src_copy(&new_instr->src[i + 1], &instr->src[i], new_instr); if (instr->dest.is_ssa) { nir_ssa_dest_init(&new_instr->instr, &new_instr->dest, diff --git a/src/compiler/nir/nir_lower_io_to_scalar.c b/src/compiler/nir/nir_lower_io_to_scalar.c index f2345d58acf..fffd1d3d2bb 100644 --- a/src/compiler/nir/nir_lower_io_to_scalar.c +++ b/src/compiler/nir/nir_lower_io_to_scalar.c @@ -49,7 +49,7 @@ lower_load_input_to_scalar(nir_builder *b, nir_intrinsic_instr *intr) nir_intrinsic_set_base(chan_intr, nir_intrinsic_base(intr)); nir_intrinsic_set_component(chan_intr, nir_intrinsic_component(intr) + i); /* offset */ - chan_intr->src[0] = intr->src[0]; + nir_src_copy(&chan_intr->src[0], &intr->src[0], chan_intr); nir_builder_instr_insert(b, &chan_intr->instr); @@ -84,7 +84,7 @@ lower_store_output_to_scalar(nir_builder *b, nir_intrinsic_instr *intr) /* value */ chan_intr->src[0] = nir_src_for_ssa(nir_channel(b, value, i)); /* offset */ - chan_intr->src[1] = intr->src[1]; + nir_src_copy(&chan_intr->src[1], &intr->src[1], chan_intr); nir_builder_instr_insert(b, &chan_intr->instr); } |