summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir/nir_to_ssa.c
diff options
context:
space:
mode:
authorRob Clark <robclark@freedesktop.org>2016-03-22 15:02:42 -0400
committerRob Clark <robclark@freedesktop.org>2016-03-24 08:30:04 -0400
commit0bea0e7141a7698118bfd465fdb4adf8e0b21bc8 (patch)
treefe0eec88ef8cdaeabbd089c05dc1efb4c3efce72 /src/compiler/nir/nir_to_ssa.c
parent4e060d80ff92b7fcf9b54cdd5ed00f549db3f573 (diff)
downloadexternal_mesa3d-0bea0e7141a7698118bfd465fdb4adf8e0b21bc8.zip
external_mesa3d-0bea0e7141a7698118bfd465fdb4adf8e0b21bc8.tar.gz
external_mesa3d-0bea0e7141a7698118bfd465fdb4adf8e0b21bc8.tar.bz2
nir: fix dangling ssadef->name ptrs
In many places, the convention is to pass an existing ssadef name ptr when construction/initializing a new nir_ssa_def. But that goes badly (as noticed by garbage in nir_print output) when the original string gets freed. Just use ralloc_strdup() instead, and add ralloc_free() in the two places that would care (not that the strings wouldn't eventually get freed anyways). Also fixup the nir_search code which was directly setting ssadef->name to use the parent instruction as memctx. Signed-off-by: Rob Clark <robclark@freedesktop.org> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Diffstat (limited to 'src/compiler/nir/nir_to_ssa.c')
-rw-r--r--src/compiler/nir/nir_to_ssa.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_to_ssa.c b/src/compiler/nir/nir_to_ssa.c
index 0640607..d588d7d 100644
--- a/src/compiler/nir/nir_to_ssa.c
+++ b/src/compiler/nir/nir_to_ssa.c
@@ -221,6 +221,7 @@ rewrite_def_forwards(nir_dest *dest, void *_state)
list_del(&dest->reg.def_link);
nir_ssa_dest_init(state->parent_instr, dest, reg->num_components,
reg->bit_size, name);
+ ralloc_free(name);
/* push our SSA destination on the stack */
state->states[index].index++;
@@ -274,6 +275,7 @@ rewrite_alu_instr_forward(nir_alu_instr *instr, rewrite_state *state)
list_del(&instr->dest.dest.reg.def_link);
nir_ssa_dest_init(&instr->instr, &instr->dest.dest, num_components,
reg->bit_size, name);
+ ralloc_free(name);
if (nir_op_infos[instr->op].output_size == 0) {
/*