glsl: add support for linear_ctx into ir_instruction

The type of the "new operator" parameter determines whether ir_instruction
is allocated with linear_ctx or ralloc. The ralloc operators will be
removed in the next commit.

GCC expects classes with virtual functions to have a virtual destructor,
but linear_ctx has static assertions that expects that no destructor is
present. Remove the assertions, as that's our only option. The destructor
is empty including in all derived classes, so it doesn't have to execute.

Acked-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Acked-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36539>
This commit is contained in:
Marek Olšák 2025-08-01 00:32:46 -04:00 committed by Marge Bot
parent ae5b168051
commit 6b2cb71560
2 changed files with 10 additions and 2 deletions

View file

@ -106,6 +106,16 @@ class ir_instruction : public ir_exec_node {
public:
enum ir_node_type ir_type;
/* The linear_ctx this node was allocated with. If NULL, it's not allocated
* with linear_ctx.
*/
linear_ctx *node_linalloc;
DECLARE_RZALLOC_CXX_OPERATORS(ir_instruction)
DECLARE_LINEAR_ZALLOC_CXX_OPERATORS(ir_instruction,
((ir_instruction*)((uintptr_t)p))->node_linalloc = ctx;,
UNREACHABLE("don't allocate ir_instruction with new[]");)
/**
* GCC 4.7+ and clang warn when deleting an ir_instruction unless
* there's a virtual destructor present. Because we almost

View file

@ -572,7 +572,6 @@ public: \
{ \
void *p = ALLOC_FUNC(ctx, size); \
assert(p != NULL); \
static_assert(HAS_TRIVIAL_DESTRUCTOR(TYPE)); \
new_cmd \
return p; \
} \
@ -580,7 +579,6 @@ public: \
{ \
void *p = ALLOC_FUNC(ctx, size); \
assert(p != NULL); \
static_assert(HAS_TRIVIAL_DESTRUCTOR(TYPE)); \
new_array_cmd \
return p; \
}