diff options
author | Jason Ekstrand <[email protected]> | 2019-05-10 14:44:45 -0500 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2019-05-13 14:43:47 +0000 |
commit | 460567eabf735003059ed24068d21b159d309896 (patch) | |
tree | c902950abb774d525cfea9ce41a2fe72778b5d1e /src | |
parent | 6963f59cae61e1736deb41f6a9e14252a36123ba (diff) |
nir/validate: Use a ralloc context for our temporary data
All of our hash tables and sets are already using ralloc. There's
really no good reason why we don't just make a ralloc context rather
than try to remember to clean everything up manually.
Reviewed-by: Eric Anholt <[email protected]>
Reviewed-by: Thomas Helland <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/nir/nir_validate.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c index 7746c391abc..3b3244b317e 100644 --- a/src/compiler/nir/nir_validate.c +++ b/src/compiler/nir/nir_validate.c @@ -61,6 +61,8 @@ typedef struct { } ssa_def_validate_state; typedef struct { + void *mem_ctx; + /* map of register -> validation state (struct above) */ struct hash_table *regs; @@ -1135,9 +1137,8 @@ validate_function_impl(nir_function_impl *impl, validate_state *state) validate_var_decl(var, false, state); } - state->regs_found = realloc(state->regs_found, - BITSET_WORDS(impl->reg_alloc) * - sizeof(BITSET_WORD)); + state->regs_found = reralloc(state->mem_ctx, state->regs_found, + BITSET_WORD, BITSET_WORDS(impl->reg_alloc)); memset(state->regs_found, 0, BITSET_WORDS(impl->reg_alloc) * sizeof(BITSET_WORD)); exec_list_validate(&impl->registers); @@ -1145,9 +1146,8 @@ validate_function_impl(nir_function_impl *impl, validate_state *state) prevalidate_reg_decl(reg, state); } - state->ssa_defs_found = realloc(state->ssa_defs_found, - BITSET_WORDS(impl->ssa_alloc) * - sizeof(BITSET_WORD)); + state->ssa_defs_found = reralloc(state->mem_ctx, state->ssa_defs_found, + BITSET_WORD, BITSET_WORDS(impl->ssa_alloc)); memset(state->ssa_defs_found, 0, BITSET_WORDS(impl->ssa_alloc) * sizeof(BITSET_WORD)); exec_list_validate(&impl->body); @@ -1177,12 +1177,13 @@ validate_function(nir_function *func, validate_state *state) static void init_validate_state(validate_state *state) { - state->regs = _mesa_pointer_hash_table_create(NULL); - state->ssa_defs = _mesa_pointer_hash_table_create(NULL); + state->mem_ctx = ralloc_context(NULL); + state->regs = _mesa_pointer_hash_table_create(state->mem_ctx); + state->ssa_defs = _mesa_pointer_hash_table_create(state->mem_ctx); state->ssa_defs_found = NULL; state->regs_found = NULL; - state->var_defs = _mesa_pointer_hash_table_create(NULL); - state->errors = _mesa_pointer_hash_table_create(NULL); + state->var_defs = _mesa_pointer_hash_table_create(state->mem_ctx); + state->errors = _mesa_pointer_hash_table_create(state->mem_ctx); state->loop = NULL; state->instr = NULL; @@ -1192,12 +1193,7 @@ init_validate_state(validate_state *state) static void destroy_validate_state(validate_state *state) { - _mesa_hash_table_destroy(state->regs, NULL); - _mesa_hash_table_destroy(state->ssa_defs, NULL); - free(state->ssa_defs_found); - free(state->regs_found); - _mesa_hash_table_destroy(state->var_defs, NULL); - _mesa_hash_table_destroy(state->errors, NULL); + ralloc_free(state->mem_ctx); } mtx_t fail_dump_mutex = _MTX_INITIALIZER_NP; |