unsigned num_ssa_defs;
unsigned bitset_words;
+ /* Used in propagate_across_edge() */
+ BITSET_WORD *tmp_live;
+
nir_block_worklist worklist;
};
propagate_across_edge(nir_block *pred, nir_block *succ,
struct live_ssa_defs_state *state)
{
- NIR_VLA(BITSET_WORD, live, state->bitset_words);
+ BITSET_WORD *live = state->tmp_live;
memcpy(live, succ->live_in, state->bitset_words * sizeof *live);
nir_foreach_instr(instr, succ) {
* blocks to the worklist.
*/
state.bitset_words = BITSET_WORDS(state.num_ssa_defs);
+ state.tmp_live = rzalloc_array(impl, BITSET_WORD, state.bitset_words);
nir_foreach_block(block, impl) {
init_liveness_block(block, &state);
}
}
}
+ ralloc_free(state.tmp_live);
nir_block_worklist_fini(&state.worklist);
}
nir_metadata_dominance);
nir_index_local_regs(impl);
+ void *dead_ctx = ralloc_context(NULL);
struct regs_to_ssa_state state;
state.shader = impl->function->shader;
- state.values = malloc(impl->reg_alloc * sizeof(*state.values));
+ state.values = ralloc_array(dead_ctx, struct nir_phi_builder_value *,
+ impl->reg_alloc);
struct nir_phi_builder *phi_build = nir_phi_builder_create(impl);
const unsigned block_set_words = BITSET_WORDS(impl->num_blocks);
- NIR_VLA(BITSET_WORD, defs, block_set_words);
+ BITSET_WORD *defs = ralloc_array(dead_ctx, BITSET_WORD, block_set_words);
nir_foreach_register(reg, &impl->registers) {
if (reg->num_array_elems != 0) {
}
}
- free(state.values);
+ ralloc_free(dead_ctx);
nir_metadata_preserve(impl, nir_metadata_block_index |
nir_metadata_dominance);
state.phi_builder = nir_phi_builder_create(state.impl);
- NIR_VLA(BITSET_WORD, store_blocks, BITSET_WORDS(state.impl->num_blocks));
+ BITSET_WORD *store_blocks =
+ ralloc_array(state.dead_ctx, BITSET_WORD,
+ BITSET_WORDS(state.impl->num_blocks));
foreach_list_typed(struct deref_node, node, direct_derefs_link,
&state.direct_deref_nodes) {
if (!node->lower_to_ssa)
nir_phi_builder_finish(struct nir_phi_builder *pb)
{
const unsigned num_blocks = pb->num_blocks;
- NIR_VLA(nir_block *, preds, num_blocks);
+ nir_block **preds = rzalloc_array(pb, nir_block *, num_blocks);
foreach_list_typed(struct nir_phi_builder_value, val, node, &pb->values) {
/* We treat the linked list of phi nodes like a worklist. The list is