[Mesa-dev] [PATCH 4/7] nir: zero allocated memory where needed

Juha-Pekka Heikkila juhapekka.heikkila at gmail.com
Tue Jun 14 14:59:03 UTC 2016


Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
---
 src/compiler/nir/nir.c             | 6 +++---
 src/compiler/nir/nir_opt_dce.c     | 2 +-
 src/compiler/nir/nir_phi_builder.c | 2 +-
 src/compiler/nir/nir_search.c      | 2 +-
 src/compiler/nir/nir_to_ssa.c      | 2 +-
 src/compiler/nir/nir_worklist.c    | 2 +-
 6 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
index 3c8b4e0..2a39c3b 100644
--- a/src/compiler/nir/nir.c
+++ b/src/compiler/nir/nir.c
@@ -34,7 +34,7 @@ nir_shader_create(void *mem_ctx,
                   gl_shader_stage stage,
                   const nir_shader_compiler_options *options)
 {
-   nir_shader *shader = ralloc(mem_ctx, nir_shader);
+   nir_shader *shader = rzalloc(mem_ctx, nir_shader);
 
    exec_list_make_empty(&shader->uniforms);
    exec_list_make_empty(&shader->inputs);
@@ -334,7 +334,7 @@ nir_function_impl_create(nir_function *function)
 nir_block *
 nir_block_create(nir_shader *shader)
 {
-   nir_block *block = ralloc(shader, nir_block);
+   nir_block *block = rzalloc(shader, nir_block);
 
    cf_init(&block->cf_node, nir_cf_node_block);
 
@@ -447,7 +447,7 @@ nir_alu_instr_create(nir_shader *shader, nir_op op)
 {
    unsigned num_srcs = nir_op_infos[op].num_inputs;
    nir_alu_instr *instr =
-      ralloc_size(shader,
+      rzalloc_size(shader,
                   sizeof(nir_alu_instr) + num_srcs * sizeof(nir_alu_src));
 
    instr_init(&instr->instr, nir_instr_type_alu);
diff --git a/src/compiler/nir/nir_opt_dce.c b/src/compiler/nir/nir_opt_dce.c
index 0aeb08a..5cefba3 100644
--- a/src/compiler/nir/nir_opt_dce.c
+++ b/src/compiler/nir/nir_opt_dce.c
@@ -131,7 +131,7 @@ init_block(nir_block *block, struct exec_list *worklist)
 static bool
 nir_opt_dce_impl(nir_function_impl *impl)
 {
-   struct exec_list *worklist = ralloc(NULL, struct exec_list);
+   struct exec_list *worklist = rzalloc(NULL, struct exec_list);
    exec_list_make_empty(worklist);
 
    nir_foreach_block(block, impl) {
diff --git a/src/compiler/nir/nir_phi_builder.c b/src/compiler/nir/nir_phi_builder.c
index dd48975..b2c5e31 100644
--- a/src/compiler/nir/nir_phi_builder.c
+++ b/src/compiler/nir/nir_phi_builder.c
@@ -81,7 +81,7 @@ struct nir_phi_builder_value {
 struct nir_phi_builder *
 nir_phi_builder_create(nir_function_impl *impl)
 {
-   struct nir_phi_builder *pb = ralloc(NULL, struct nir_phi_builder);
+   struct nir_phi_builder *pb = rzalloc(NULL, struct nir_phi_builder);
 
    pb->shader = impl->function->shader;
    pb->impl = impl;
diff --git a/src/compiler/nir/nir_search.c b/src/compiler/nir/nir_search.c
index b21fb2c..db1d8da 100644
--- a/src/compiler/nir/nir_search.c
+++ b/src/compiler/nir/nir_search.c
@@ -329,7 +329,7 @@ static bitsize_tree *
 build_bitsize_tree(void *mem_ctx, struct match_state *state,
                    const nir_search_value *value)
 {
-   bitsize_tree *tree = ralloc(mem_ctx, bitsize_tree);
+   bitsize_tree *tree = rzalloc(mem_ctx, bitsize_tree);
 
    switch (value->type) {
    case nir_search_value_expression: {
diff --git a/src/compiler/nir/nir_to_ssa.c b/src/compiler/nir/nir_to_ssa.c
index 6accdd2..e0998d4 100644
--- a/src/compiler/nir/nir_to_ssa.c
+++ b/src/compiler/nir/nir_to_ssa.c
@@ -476,7 +476,7 @@ init_rewrite_state(nir_function_impl *impl, rewrite_state *state)
    state->mem_ctx = ralloc_parent(impl);
    state->ssa_map = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
                                             _mesa_key_pointer_equal);
-   state->states = ralloc_array(NULL, reg_state, impl->reg_alloc);
+   state->states = rzalloc_array(NULL, reg_state, impl->reg_alloc);
 
    foreach_list_typed(nir_register, reg, node, &impl->registers) {
       assert(reg->index < impl->reg_alloc);
diff --git a/src/compiler/nir/nir_worklist.c b/src/compiler/nir/nir_worklist.c
index 3ae2770..75e9426 100644
--- a/src/compiler/nir/nir_worklist.c
+++ b/src/compiler/nir/nir_worklist.c
@@ -37,7 +37,7 @@ nir_block_worklist_init(nir_block_worklist *w, unsigned num_blocks,
 
    w->blocks_present = rzalloc_array(mem_ctx, BITSET_WORD,
                                      BITSET_WORDS(num_blocks));
-   w->blocks = ralloc_array(mem_ctx, nir_block *, num_blocks);
+   w->blocks = rzalloc_array(mem_ctx, nir_block *, num_blocks);
 }
 
 void
-- 
1.9.1



More information about the mesa-dev mailing list