nir: Consistently pass the shader to the shader arg of instr creation.

We were using the ralloc parent in some places, which should work out to
be the shader I think, but to de-ralloc the instrs we should just pass the
existing shader pointer in.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11776>
This commit is contained in:
Emma Anholt 2021-07-07 10:49:32 -07:00 committed by Marge Bot
parent 7a4bbe60c1
commit 5e37cfb7fe
5 changed files with 11 additions and 12 deletions

View File

@ -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);

View File

@ -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]);

View File

@ -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

View File

@ -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);

View File

@ -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,