nir: fix dangling ssadef->name ptrs
authorRob Clark <robclark@freedesktop.org>
Tue, 22 Mar 2016 19:02:42 +0000 (15:02 -0400)
committerRob Clark <robclark@freedesktop.org>
Thu, 24 Mar 2016 12:30:04 +0000 (08:30 -0400)
commit0bea0e7141a7698118bfd465fdb4adf8e0b21bc8
treefe0eec88ef8cdaeabbd089c05dc1efb4c3efce72
parent4e060d80ff92b7fcf9b54cdd5ed00f549db3f573
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>
src/compiler/nir/nir.c
src/compiler/nir/nir_search.c
src/compiler/nir/nir_to_ssa.c