From 903e5eae974c125c2605fad465f7cf6863143199 Mon Sep 17 00:00:00 2001 From: Timothy Arceri Date: Thu, 3 Nov 2016 09:18:19 +1100 Subject: nir: fix nir_shader_clone() and nir_sweep() These were broken in e1af20f18a8 when the info field in nir_shader was turned into a pointer. Clone was copying the pointer rather than the data and nir_sweep was cleaning up shader_info rather than claiming it. Reviewed-by: Eric Anholt --- src/compiler/nir/nir_clone.c | 2 +- src/compiler/nir/nir_sweep.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src/compiler/nir') diff --git a/src/compiler/nir/nir_clone.c b/src/compiler/nir/nir_clone.c index f23fabc7015..4f7bdd96969 100644 --- a/src/compiler/nir/nir_clone.c +++ b/src/compiler/nir/nir_clone.c @@ -710,7 +710,7 @@ nir_shader_clone(void *mem_ctx, const nir_shader *s) clone_reg_list(&state, &ns->registers, &s->registers); ns->reg_alloc = s->reg_alloc; - ns->info = s->info; + *ns->info = *s->info; ns->info->name = ralloc_strdup(ns, ns->info->name); if (ns->info->label) ns->info->label = ralloc_strdup(ns, ns->info->label); diff --git a/src/compiler/nir/nir_sweep.c b/src/compiler/nir/nir_sweep.c index faf696d6dec..e6ae298dd36 100644 --- a/src/compiler/nir/nir_sweep.c +++ b/src/compiler/nir/nir_sweep.c @@ -150,9 +150,17 @@ nir_sweep(nir_shader *nir) { void *rubbish = ralloc_context(NULL); + /* The shader may not own shader_info so check first */ + bool steal_info = false; + if (nir == ralloc_parent(nir->info)) + steal_info = true; + /* First, move ownership of all the memory to a temporary context; assume dead. */ ralloc_adopt(rubbish, nir); + if (steal_info) + ralloc_steal(nir, nir->info); + ralloc_steal(nir, (char *)nir->info->name); if (nir->info->label) ralloc_steal(nir, (char *)nir->info->label); -- cgit v1.2.3