summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2019-07-22 00:51:24 -0500
committerJason Ekstrand <[email protected]>2019-07-22 16:17:18 -0500
commit5c5f11d1dd3b52e80483f132236c690cbbc3ea0b (patch)
tree4c553ebc8481c73372b0fae746877687ccf30e8d
parentfa63fad3332309afa14fea68c87cf6aa138fb45c (diff)
nir: Remove a bunch of large stack arrays
Reviewed-by: Lionel Landwerlin <[email protected]> Reviewed-by: Matt Turner <[email protected]>
-rw-r--r--src/compiler/nir/nir_liveness.c7
-rw-r--r--src/compiler/nir/nir_lower_regs_to_ssa.c8
-rw-r--r--src/compiler/nir/nir_lower_vars_to_ssa.c4
-rw-r--r--src/compiler/nir/nir_phi_builder.c2
4 files changed, 15 insertions, 6 deletions
diff --git a/src/compiler/nir/nir_liveness.c b/src/compiler/nir/nir_liveness.c
index 03e252fbfd8..16dbeb4a223 100644
--- a/src/compiler/nir/nir_liveness.c
+++ b/src/compiler/nir/nir_liveness.c
@@ -46,6 +46,9 @@ struct live_ssa_defs_state {
unsigned num_ssa_defs;
unsigned bitset_words;
+ /* Used in propagate_across_edge() */
+ BITSET_WORD *tmp_live;
+
nir_block_worklist worklist;
};
@@ -121,7 +124,7 @@ static bool
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) {
@@ -176,6 +179,7 @@ nir_live_ssa_defs_impl(nir_function_impl *impl)
* 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);
}
@@ -225,6 +229,7 @@ nir_live_ssa_defs_impl(nir_function_impl *impl)
}
}
+ ralloc_free(state.tmp_live);
nir_block_worklist_fini(&state.worklist);
}
diff --git a/src/compiler/nir/nir_lower_regs_to_ssa.c b/src/compiler/nir/nir_lower_regs_to_ssa.c
index 76ed1287379..b755d1df99e 100644
--- a/src/compiler/nir/nir_lower_regs_to_ssa.c
+++ b/src/compiler/nir/nir_lower_regs_to_ssa.c
@@ -220,14 +220,16 @@ nir_lower_regs_to_ssa_impl(nir_function_impl *impl)
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) {
@@ -305,7 +307,7 @@ nir_lower_regs_to_ssa_impl(nir_function_impl *impl)
}
}
- free(state.values);
+ ralloc_free(dead_ctx);
nir_metadata_preserve(impl, nir_metadata_block_index |
nir_metadata_dominance);
diff --git a/src/compiler/nir/nir_lower_vars_to_ssa.c b/src/compiler/nir/nir_lower_vars_to_ssa.c
index 4375f93dc3c..c685b7ffa0c 100644
--- a/src/compiler/nir/nir_lower_vars_to_ssa.c
+++ b/src/compiler/nir/nir_lower_vars_to_ssa.c
@@ -768,7 +768,9 @@ nir_lower_vars_to_ssa_impl(nir_function_impl *impl)
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)
diff --git a/src/compiler/nir/nir_phi_builder.c b/src/compiler/nir/nir_phi_builder.c
index 621777d6ecc..97edea777f4 100644
--- a/src/compiler/nir/nir_phi_builder.c
+++ b/src/compiler/nir/nir_phi_builder.c
@@ -277,7 +277,7 @@ void
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