From 23bea252073c525fe8857b4334465705984dbc40 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 12 Oct 2023 12:03:42 -0400 Subject: [PATCH] nir: Add nir_remove_non_exported For libraries. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Konstantin Seurer Reviewed-by: Karol Herbst Reviewed-by: Faith Ekstrand Part-of: --- src/compiler/nir/nir.c | 9 +++++++++ src/compiler/nir/nir.h | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c index 0de2138ca0c..3143fc8201f 100644 --- a/src/compiler/nir/nir.c +++ b/src/compiler/nir/nir.c @@ -3401,3 +3401,12 @@ nir_remove_non_entrypoints(nir_shader *nir) } assert(exec_list_length(&nir->functions) == 1); } + +void +nir_remove_non_exported(nir_shader *nir) +{ + nir_foreach_function_safe(func, nir) { + if (!func->is_exported) + exec_node_remove(&func->node); + } +} diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 74985f9f336..69e6912004a 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -4150,7 +4150,12 @@ nir_shader_get_function_for_name(const nir_shader *shader, const char *name) return NULL; } +/* + * After all functions are forcibly inlined, these passes remove redundant + * functions from a shader and library respectively. + */ void nir_remove_non_entrypoints(nir_shader *shader); +void nir_remove_non_exported(nir_shader *shader); nir_shader *nir_shader_create(void *mem_ctx, gl_shader_stage stage,