diff options
author | Marek Olšák <[email protected]> | 2016-10-07 00:34:26 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2016-10-31 11:53:38 +0100 |
commit | 52d2b28f7f107fbaff023533a15058055fa73bf0 (patch) | |
tree | b6f1de58134f1d10fc9dd766b81945021b53513a /src/compiler | |
parent | 9454f7c0ef55a9357473e451f0f59432c9438f01 (diff) |
ralloc: use rzalloc where it's necessary
No change in behavior. ralloc_size is equivalent to rzalloc_size.
That will change though.
Calls not switched to rzalloc_size:
- ralloc_vasprintf
- glsl_type::name allocation (it's filled with snprintf)
- C++ classes where valgrind didn't show uninitialized values
I switched most of non-glsl stuff to rzalloc without checking whether
it's really needed.
Reviewed-by: Edward O'Callaghan <[email protected]>
Tested-by: Edmondo Tommasina <[email protected]>
Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/glsl/ast.h | 2 | ||||
-rw-r--r-- | src/compiler/glsl/ast_to_hir.cpp | 4 | ||||
-rw-r--r-- | src/compiler/glsl/glsl_parser_extras.h | 2 | ||||
-rw-r--r-- | src/compiler/glsl/link_uniform_blocks.cpp | 2 | ||||
-rw-r--r-- | src/compiler/glsl/list.h | 2 | ||||
-rw-r--r-- | src/compiler/nir/nir.c | 8 | ||||
-rw-r--r-- | src/compiler/spirv/vtn_variables.c | 3 |
7 files changed, 13 insertions, 10 deletions
diff --git a/src/compiler/glsl/ast.h b/src/compiler/glsl/ast.h index 55f009ac857..063a9b43af0 100644 --- a/src/compiler/glsl/ast.h +++ b/src/compiler/glsl/ast.h @@ -49,7 +49,7 @@ struct YYLTYPE; */ class ast_node { public: - DECLARE_RALLOC_CXX_OPERATORS(ast_node); + DECLARE_RZALLOC_CXX_OPERATORS(ast_node); /** * Print an AST node in something approximating the original GLSL code diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp index a9a1ba3c48c..24067b6ac0c 100644 --- a/src/compiler/glsl/ast_to_hir.cpp +++ b/src/compiler/glsl/ast_to_hir.cpp @@ -6639,8 +6639,8 @@ ast_process_struct_or_iface_block_members(exec_list *instructions, * the types to HIR. This ensures that structure definitions embedded in * other structure definitions or in interface blocks are processed. */ - glsl_struct_field *const fields = ralloc_array(state, glsl_struct_field, - decl_count); + glsl_struct_field *const fields = rzalloc_array(state, glsl_struct_field, + decl_count); bool first_member = true; bool first_member_has_explicit_location = false; diff --git a/src/compiler/glsl/glsl_parser_extras.h b/src/compiler/glsl/glsl_parser_extras.h index 5bdebf684bb..e50d08ad38c 100644 --- a/src/compiler/glsl/glsl_parser_extras.h +++ b/src/compiler/glsl/glsl_parser_extras.h @@ -76,7 +76,7 @@ struct _mesa_glsl_parse_state { _mesa_glsl_parse_state(struct gl_context *_ctx, gl_shader_stage stage, void *mem_ctx); - DECLARE_RALLOC_CXX_OPERATORS(_mesa_glsl_parse_state); + DECLARE_RZALLOC_CXX_OPERATORS(_mesa_glsl_parse_state); /** * Generate a string representing the GLSL version currently being compiled diff --git a/src/compiler/glsl/link_uniform_blocks.cpp b/src/compiler/glsl/link_uniform_blocks.cpp index c0bdfa934e0..1fc0e2d5109 100644 --- a/src/compiler/glsl/link_uniform_blocks.cpp +++ b/src/compiler/glsl/link_uniform_blocks.cpp @@ -310,7 +310,7 @@ create_buffer_blocks(void *mem_ctx, struct gl_context *ctx, /* Allocate storage to hold all of the information related to uniform * blocks that can be queried through the API. */ - struct gl_uniform_block *blocks = ralloc_array(mem_ctx, gl_uniform_block, num_blocks); + struct gl_uniform_block *blocks = rzalloc_array(mem_ctx, gl_uniform_block, num_blocks); gl_uniform_buffer_variable *variables = ralloc_array(blocks, gl_uniform_buffer_variable, num_variables); diff --git a/src/compiler/glsl/list.h b/src/compiler/glsl/list.h index b5b5b362afd..6afb9dcef94 100644 --- a/src/compiler/glsl/list.h +++ b/src/compiler/glsl/list.h @@ -56,7 +56,7 @@ struct exec_node { struct exec_node *prev; #ifdef __cplusplus - DECLARE_RALLOC_CXX_OPERATORS(exec_node) + DECLARE_RZALLOC_CXX_OPERATORS(exec_node) exec_node() : next(NULL), prev(NULL) { diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c index 31f0bcb8d81..cfb032c68b9 100644 --- a/src/compiler/nir/nir.c +++ b/src/compiler/nir/nir.c @@ -448,9 +448,10 @@ nir_alu_instr * nir_alu_instr_create(nir_shader *shader, nir_op op) { unsigned num_srcs = nir_op_infos[op].num_inputs; + /* TODO: don't use rzalloc */ nir_alu_instr *instr = - ralloc_size(shader, - sizeof(nir_alu_instr) + num_srcs * sizeof(nir_alu_src)); + rzalloc_size(shader, + sizeof(nir_alu_instr) + num_srcs * sizeof(nir_alu_src)); instr_init(&instr->instr, nir_instr_type_alu); instr->op = op; @@ -486,8 +487,9 @@ nir_intrinsic_instr * nir_intrinsic_instr_create(nir_shader *shader, nir_intrinsic_op op) { unsigned num_srcs = nir_intrinsic_infos[op].num_srcs; + /* TODO: don't use rzalloc */ nir_intrinsic_instr *instr = - ralloc_size(shader, + rzalloc_size(shader, sizeof(nir_intrinsic_instr) + num_srcs * sizeof(nir_src)); instr_init(&instr->instr, nir_instr_type_intrinsic); diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c index c9744c4513d..bbcca146107 100644 --- a/src/compiler/spirv/vtn_variables.c +++ b/src/compiler/spirv/vtn_variables.c @@ -35,7 +35,8 @@ vtn_access_chain_extend(struct vtn_builder *b, struct vtn_access_chain *old, struct vtn_access_chain *chain; unsigned new_len = old->length + new_ids; - chain = ralloc_size(b, sizeof(*chain) + new_len * sizeof(chain->link[0])); + /* TODO: don't use rzalloc */ + chain = rzalloc_size(b, sizeof(*chain) + new_len * sizeof(chain->link[0])); chain->var = old->var; chain->length = new_len; |