From 6b2cb7156095154e77395f76fb809b0bad20d933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 1 Aug 2025 00:32:46 -0400 Subject: [PATCH] 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 Acked-by: Timothy Arceri Part-of: --- src/compiler/glsl/ir.h | 10 ++++++++++ src/util/ralloc.h | 2 -- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/compiler/glsl/ir.h b/src/compiler/glsl/ir.h index 900c15245a3..73ebf2324c0 100644 --- a/src/compiler/glsl/ir.h +++ b/src/compiler/glsl/ir.h @@ -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 diff --git a/src/util/ralloc.h b/src/util/ralloc.h index e52f1000cd5..f3fe3c951ce 100644 --- a/src/util/ralloc.h +++ b/src/util/ralloc.h @@ -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; \ }