From 593308a685632a2d2b1c739255553d41a6ddd803 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 24 Feb 2025 15:25:10 -0500 Subject: [PATCH] nir: eliminate nir_metadata_preserve Everybody uses the wrapper now. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Georg Lehmann Reviewed-by: Faith Ekstrand Part-of: --- src/compiler/nir/nir.h | 18 +++++------------- src/compiler/nir/nir_metadata.c | 9 +++++++-- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index f14c9a49237..b8506163e90 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -3893,24 +3893,16 @@ nir_function_impl *nir_cf_node_get_function(nir_cf_node *node); /** requests that the given pieces of metadata be generated */ void nir_metadata_require(nir_function_impl *impl, nir_metadata required, ...); -/** dirties all but the preserved metadata */ -void nir_metadata_preserve(nir_function_impl *impl, nir_metadata preserved); /** Preserves all metadata for the given shader */ void nir_shader_preserve_all_metadata(nir_shader *shader); /** dirties all metadata and fills it with obviously wrong information */ void nir_metadata_invalidate(nir_shader *shader); -static inline bool -nir_progress(bool progress, nir_function_impl *impl, nir_metadata preserved) -{ - if (progress) { - nir_metadata_preserve(impl, preserved); - } else { - nir_metadata_preserve(impl, nir_metadata_all); - } - - return progress; -} +/** + * Indicate progress on an implementation, preserving only the specified + * metadata. The supplied progress is returned to improve ergonomics. + */ +bool nir_progress(bool progress, nir_function_impl *impl, nir_metadata preserved); /** Indicate that there is no progress. All metadata is preserved. */ static inline bool diff --git a/src/compiler/nir/nir_metadata.c b/src/compiler/nir/nir_metadata.c index 24176dd6171..3cd16a72581 100644 --- a/src/compiler/nir/nir_metadata.c +++ b/src/compiler/nir/nir_metadata.c @@ -66,9 +66,13 @@ nir_metadata_require(nir_function_impl *impl, nir_metadata required, ...) impl->valid_metadata |= required; } -void -nir_metadata_preserve(nir_function_impl *impl, nir_metadata preserved) +bool +nir_progress(bool progress, nir_function_impl *impl, nir_metadata preserved) { + /* If we do not make progress, we preserve all metadata. */ + if (!progress) + preserved = nir_metadata_all; + /* If we discard valid liveness information, immediately free the * liveness information for each block. For large shaders, it can * consume a huge amount of memory, and it's usually not immediately @@ -83,6 +87,7 @@ nir_metadata_preserve(nir_function_impl *impl, nir_metadata preserved) } impl->valid_metadata &= preserved; + return progress; } void