util: Remove size from linear_parent creation
authorCaio Oliveira <caio.oliveira@intel.com>
Mon, 18 Sep 2023 06:11:58 +0000 (23:11 -0700)
committerMarge Bot <emma+marge@anholt.net>
Mon, 25 Sep 2023 17:26:17 +0000 (17:26 +0000)
None of the callsites took advantage of this, so remove
the feature.  This will help to a next change that will
add an opaque type to represent a linear parent.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25280>

src/compiler/glsl/glcpp/glcpp-parse.y
src/compiler/glsl/glsl_parser_extras.cpp
src/compiler/glsl/glsl_symbol_table.cpp
src/compiler/glsl/opt_dead_code_local.cpp
src/compiler/glsl_types.cpp
src/compiler/nir/nir_opt_combine_stores.c
src/compiler/nir/nir_opt_copy_prop_vars.c
src/compiler/nir/tests/vars_tests.cpp
src/util/ralloc.c
src/util/ralloc.h

index 3638560..15dcc14 100644 (file)
@@ -1497,7 +1497,7 @@ glcpp_parser_create(struct gl_context *gl_ctx,
    glcpp_lex_init_extra (parser, &parser->scanner);
    parser->defines = _mesa_hash_table_create(NULL, _mesa_hash_string,
                                              _mesa_key_string_equal);
-   parser->linalloc = linear_alloc_parent(parser, 0);
+   parser->linalloc = linear_alloc_parent(parser);
    parser->active = NULL;
    parser->lexing_directive = 0;
    parser->lexing_version_directive = 0;
index 7622fde..bade333 100644 (file)
@@ -71,7 +71,7 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
    this->translation_unit.make_empty();
    this->symbols = new(mem_ctx) glsl_symbol_table;
 
-   this->linalloc = linear_alloc_parent(this, 0);
+   this->linalloc = linear_alloc_parent(this);
 
    this->info_log = ralloc_strdup(mem_ctx, "");
    this->error = false;
index 9ae5fd3..7dc965d 100644 (file)
@@ -106,7 +106,7 @@ glsl_symbol_table::glsl_symbol_table()
    this->separate_function_namespace = false;
    this->table = _mesa_symbol_table_ctor();
    this->mem_ctx = ralloc_context(NULL);
-   this->linalloc = linear_alloc_parent(this->mem_ctx, 0);
+   this->linalloc = linear_alloc_parent(this->mem_ctx);
 }
 
 glsl_symbol_table::~glsl_symbol_table()
index b89519b..afb242c 100644 (file)
@@ -310,7 +310,7 @@ dead_code_local_basic_block(ir_instruction *first,
    bool progress = false;
 
    void *ctx = ralloc_context(NULL);
-   void *lin_ctx = linear_alloc_parent(ctx, 0);
+   void *lin_ctx = linear_alloc_parent(ctx);
 
    /* Safe looping, since process_assignment */
    for (ir = first, ir_next = (ir_instruction *)first->next;;
index ff2ce07..aa04855 100644 (file)
@@ -455,7 +455,7 @@ glsl_type_singleton_init_or_ref()
    simple_mtx_lock(&glsl_type_cache_mutex);
    if (glsl_type_cache.users == 0) {
       glsl_type_cache.mem_ctx = ralloc_context(NULL);
-      glsl_type_cache.lin_ctx = linear_zalloc_parent(glsl_type_cache.mem_ctx, 0);
+      glsl_type_cache.lin_ctx = linear_alloc_parent(glsl_type_cache.mem_ctx);
    }
    glsl_type_cache.users++;
    simple_mtx_unlock(&glsl_type_cache_mutex);
index 486905f..42e3b0f 100644 (file)
@@ -417,7 +417,7 @@ nir_opt_combine_stores(nir_shader *shader, nir_variable_mode modes)
    void *mem_ctx = ralloc_context(NULL);
    struct combine_stores_state state = {
       .modes = modes,
-      .lin_ctx = linear_zalloc_parent(mem_ctx, 0),
+      .lin_ctx = linear_alloc_parent(mem_ctx),
    };
 
    list_inithead(&state.pending);
index efdd2dd..fd58b87 100644 (file)
@@ -1482,7 +1482,7 @@ nir_copy_prop_vars_impl(nir_function_impl *impl)
    struct copy_prop_var_state state = {
       .impl = impl,
       .mem_ctx = mem_ctx,
-      .lin_ctx = linear_zalloc_parent(mem_ctx, 0),
+      .lin_ctx = linear_alloc_parent(mem_ctx),
 
       .vars_written_map = _mesa_pointer_hash_table_create(mem_ctx),
    };
index 53bf6cf..ee85208 100644 (file)
@@ -96,7 +96,7 @@ protected:
 nir_vars_test::nir_vars_test()
    : nir_test::nir_test("nir_vars_test")
 {
-   lin_ctx = linear_alloc_parent(b->shader, 0);
+   lin_ctx = linear_alloc_parent(b->shader);
 }
 
 nir_vars_test::~nir_vars_test()
index 278d671..d689285 100644 (file)
@@ -991,10 +991,6 @@ struct linear_size_chunk {
 typedef struct linear_header linear_header;
 typedef struct linear_size_chunk linear_size_chunk;
 
-#define LINEAR_PARENT_TO_HEADER(parent) \
-   (linear_header*) \
-   ((char*)(parent) - sizeof(linear_size_chunk) - sizeof(linear_header))
-
 /* Allocate the linear buffer with its header. */
 static linear_header *
 create_linear_node(void *ralloc_ctx, unsigned min_size)
@@ -1022,7 +1018,7 @@ create_linear_node(void *ralloc_ctx, unsigned min_size)
 void *
 linear_alloc_child(void *parent, unsigned size)
 {
-   linear_header *first = LINEAR_PARENT_TO_HEADER(parent);
+   linear_header *first = parent;
    linear_header *latest = first->latest;
    linear_header *new_node;
    linear_size_chunk *ptr;
@@ -1054,22 +1050,18 @@ linear_alloc_child(void *parent, unsigned size)
 }
 
 void *
-linear_alloc_parent(void *ralloc_ctx, unsigned size)
+linear_alloc_parent(void *ralloc_ctx)
 {
    linear_header *node;
 
    if (unlikely(!ralloc_ctx))
       return NULL;
 
-   size = ALIGN_POT(size, SUBALLOC_ALIGNMENT);
-
-   node = create_linear_node(ralloc_ctx, size);
+   node = create_linear_node(ralloc_ctx, 0);
    if (unlikely(!node))
       return NULL;
 
-   return linear_alloc_child((char*)node +
-                             sizeof(linear_header) +
-                             sizeof(linear_size_chunk), size);
+   return node;
 }
 
 void *
@@ -1082,23 +1074,13 @@ linear_zalloc_child(void *parent, unsigned size)
    return ptr;
 }
 
-void *
-linear_zalloc_parent(void *parent, unsigned size)
-{
-   void *ptr = linear_alloc_parent(parent, size);
-
-   if (likely(ptr))
-      memset(ptr, 0, size);
-   return ptr;
-}
-
 void
 linear_free_parent(void *ptr)
 {
    if (unlikely(!ptr))
       return;
 
-   linear_header *first = LINEAR_PARENT_TO_HEADER(ptr);
+   linear_header *first = ptr;
    assert(first->magic == LMAGIC);
 
    /* Other nodes are ralloc children of the first node. */
@@ -1111,7 +1093,7 @@ ralloc_steal_linear_parent(void *new_ralloc_ctx, void *ptr)
    if (unlikely(!ptr))
       return;
 
-   linear_header *first = LINEAR_PARENT_TO_HEADER(ptr);
+   linear_header *first = ptr;
    assert(first->magic == LMAGIC);
 
    /* Other nodes are ralloc children of the first node. */
@@ -1121,7 +1103,7 @@ ralloc_steal_linear_parent(void *new_ralloc_ctx, void *ptr)
 void *
 ralloc_parent_of_linear_parent(void *ptr)
 {
-   linear_header *node = LINEAR_PARENT_TO_HEADER(ptr);
+   linear_header *node = ptr;
    assert(node->magic == LMAGIC);
    return PTR_FROM_HEADER(get_header(node)->parent);
 }
index 5bb0f52..47a0f40 100644 (file)
@@ -556,7 +556,6 @@ public:                                                                  \
 #define DECLARE_LINEAR_ZALLOC_CXX_OPERATORS(type) \
    DECLARE_ALLOC_CXX_OPERATORS_TEMPLATE(type, linear_zalloc_child)
 
-
 /**
  * Do a fast allocation from the linear buffer, also known as the child node
  * from the allocator's point of view. It can't be freed directly. You have
@@ -568,14 +567,12 @@ public:                                                                  \
 void *linear_alloc_child(void *parent, unsigned size) MALLOCLIKE;
 
 /**
- * Allocate a parent node that will hold linear buffers. The returned
- * allocation is actually the first child node, but it's also the handle
- * of the parent node. Use it for all child node allocations.
+ * Allocate a parent node that will hold linear buffers.
+ * Use it for all child node allocations.
  *
  * \param ralloc_ctx  ralloc context, must not be NULL
- * \param size        size to allocate (max 32 bits)
  */
-void *linear_alloc_parent(void *ralloc_ctx, unsigned size) MALLOCLIKE;
+void *linear_alloc_parent(void *ralloc_ctx);
 
 /**
  * Same as linear_alloc_child, but also clears memory.
@@ -583,11 +580,6 @@ void *linear_alloc_parent(void *ralloc_ctx, unsigned size) MALLOCLIKE;
 void *linear_zalloc_child(void *parent, unsigned size) MALLOCLIKE;
 
 /**
- * Same as linear_alloc_parent, but also clears memory.
- */
-void *linear_zalloc_parent(void *ralloc_ctx, unsigned size) MALLOCLIKE;
-
-/**
  * Free the linear parent node. This will free all child nodes too.
  * Freeing the ralloc parent will also free this.
  */