diff --git a/src/compiler/nir/nir_control_flow.c b/src/compiler/nir/nir_control_flow.c index 6cf0f1add5a..433aa18a39a 100644 --- a/src/compiler/nir/nir_control_flow.c +++ b/src/compiler/nir/nir_control_flow.c @@ -236,7 +236,7 @@ nir_insert_phi_undef(nir_block *block, nir_block *pred) nir_phi_instr *phi = nir_instr_as_phi(instr); nir_ssa_undef_instr *undef = - nir_ssa_undef_instr_create(ralloc_parent(phi), + nir_ssa_undef_instr_create(impl->function->shader, phi->dest.ssa.num_components, phi->dest.ssa.bit_size); nir_instr_insert_before_cf_list(&impl->body, &undef->instr); @@ -607,10 +607,10 @@ static bool replace_ssa_def_uses(nir_ssa_def *def, void *void_impl) { nir_function_impl *impl = void_impl; - void *mem_ctx = ralloc_parent(impl); nir_ssa_undef_instr *undef = - nir_ssa_undef_instr_create(mem_ctx, def->num_components, + nir_ssa_undef_instr_create(impl->function->shader, + def->num_components, def->bit_size); nir_instr_insert_before_cf_list(&impl->body, &undef->instr); nir_ssa_def_rewrite_uses(def, &undef->def); diff --git a/src/compiler/nir/nir_from_ssa.c b/src/compiler/nir/nir_from_ssa.c index 6880c45c774..36ff0b296e0 100644 --- a/src/compiler/nir/nir_from_ssa.c +++ b/src/compiler/nir/nir_from_ssa.c @@ -303,7 +303,6 @@ merge_sets_interfere(merge_set *a, merge_set *b) static bool add_parallel_copy_to_end_of_block(nir_shader *shader, nir_block *block, void *dead_ctx) { - bool need_end_copy = false; if (block->successors[0]) { nir_instr *instr = nir_block_first_instr(block->successors[0]); diff --git a/src/compiler/nir/nir_lower_atomics_to_ssbo.c b/src/compiler/nir/nir_lower_atomics_to_ssbo.c index 99b6612e00a..76bfeca4f54 100644 --- a/src/compiler/nir/nir_lower_atomics_to_ssbo.c +++ b/src/compiler/nir/nir_lower_atomics_to_ssbo.c @@ -89,7 +89,7 @@ lower_instr(nir_intrinsic_instr *instr, unsigned ssbo_offset, nir_builder *b) nir_ssa_def *buffer = nir_imm_int(b, ssbo_offset + nir_intrinsic_base(instr)); nir_ssa_def *temp = NULL; nir_intrinsic_instr *new_instr = - nir_intrinsic_instr_create(ralloc_parent(instr), op); + nir_intrinsic_instr_create(b->shader, op); /* a couple instructions need special handling since they don't map * 1:1 with ssbo atomics diff --git a/src/compiler/nir/nir_lower_phis_to_scalar.c b/src/compiler/nir/nir_lower_phis_to_scalar.c index 2fcd71d70ce..eb7eb09bb80 100644 --- a/src/compiler/nir/nir_lower_phis_to_scalar.c +++ b/src/compiler/nir/nir_lower_phis_to_scalar.c @@ -33,6 +33,7 @@ */ struct lower_phis_to_scalar_state { + nir_shader *shader; void *mem_ctx; void *dead_ctx; @@ -219,14 +220,14 @@ lower_phis_to_scalar_block(nir_block *block, */ nir_op vec_op = nir_op_vec(phi->dest.ssa.num_components); - nir_alu_instr *vec = nir_alu_instr_create(state->mem_ctx, vec_op); + nir_alu_instr *vec = nir_alu_instr_create(state->shader, vec_op); nir_ssa_dest_init(&vec->instr, &vec->dest.dest, phi->dest.ssa.num_components, bit_size, NULL); vec->dest.write_mask = (1 << phi->dest.ssa.num_components) - 1; for (unsigned i = 0; i < phi->dest.ssa.num_components; i++) { - nir_phi_instr *new_phi = nir_phi_instr_create(state->mem_ctx); + nir_phi_instr *new_phi = nir_phi_instr_create(state->shader); nir_ssa_dest_init(&new_phi->instr, &new_phi->dest, 1, phi->dest.ssa.bit_size, NULL); @@ -234,7 +235,7 @@ lower_phis_to_scalar_block(nir_block *block, nir_foreach_phi_src(src, phi) { /* We need to insert a mov to grab the i'th component of src */ - nir_alu_instr *mov = nir_alu_instr_create(state->mem_ctx, + nir_alu_instr *mov = nir_alu_instr_create(state->shader, nir_op_mov); nir_ssa_dest_init(&mov->instr, &mov->dest.dest, 1, bit_size, NULL); mov->dest.write_mask = 1; @@ -283,6 +284,7 @@ lower_phis_to_scalar_impl(nir_function_impl *impl, bool lower_all) struct lower_phis_to_scalar_state state; bool progress = false; + state.shader = impl->function->shader; state.mem_ctx = ralloc_parent(impl); state.dead_ctx = ralloc_context(NULL); state.phi_table = _mesa_pointer_hash_table_create(state.dead_ctx); diff --git a/src/compiler/nir/nir_opt_comparison_pre.c b/src/compiler/nir/nir_opt_comparison_pre.c index ae35e2c8d09..f48dbe59d04 100644 --- a/src/compiler/nir/nir_opt_comparison_pre.c +++ b/src/compiler/nir/nir_opt_comparison_pre.c @@ -139,8 +139,6 @@ static void rewrite_compare_instruction(nir_builder *bld, nir_alu_instr *orig_cmp, nir_alu_instr *orig_add, bool zero_on_left) { - void *const mem_ctx = ralloc_parent(orig_cmp); - bld->cursor = nir_before_instr(&orig_cmp->instr); /* This is somewhat tricky. The compare instruction may be something like @@ -174,7 +172,7 @@ rewrite_compare_instruction(nir_builder *bld, nir_alu_instr *orig_cmp, * will clean these up. This is similar to nir_replace_instr (in * nir_search.c). */ - nir_alu_instr *mov_add = nir_alu_instr_create(mem_ctx, nir_op_mov); + nir_alu_instr *mov_add = nir_alu_instr_create(bld->shader, nir_op_mov); mov_add->dest.write_mask = orig_add->dest.write_mask; nir_ssa_dest_init(&mov_add->instr, &mov_add->dest.dest, orig_add->dest.dest.ssa.num_components, @@ -183,7 +181,7 @@ rewrite_compare_instruction(nir_builder *bld, nir_alu_instr *orig_cmp, nir_builder_instr_insert(bld, &mov_add->instr); - nir_alu_instr *mov_cmp = nir_alu_instr_create(mem_ctx, nir_op_mov); + nir_alu_instr *mov_cmp = nir_alu_instr_create(bld->shader, nir_op_mov); mov_cmp->dest.write_mask = orig_cmp->dest.write_mask; nir_ssa_dest_init(&mov_cmp->instr, &mov_cmp->dest.dest, orig_cmp->dest.dest.ssa.num_components,