From f66a7240f9f2d231c105ed0d79c10ac8d9780874 Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Fri, 26 Feb 2021 09:08:56 +0000 Subject: [PATCH] nir: fix build at -O1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit At -O1 with GCC 10.2.1, _nir_visit_dest_indirect (declared ALWAYS_INLINE) will fail to inline if it's caller (nir_foreach_dest) is not inlined, because _nir_visit_dest_indirect is passed as a function pointer. This results in a compilation error. Signed-off-by: Rhys Perry Acked-by: Jason Ekstrand Reviewed-by: Daniel Schürmann Reviewed-by: Witold Baryluk Fixes: 336bcbacd05 ("nir: inline nir_foreach_{src,dest}") Tested-by: Witold Baryluk Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4353 Part-of: --- src/compiler/nir/nir_inline_helpers.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/compiler/nir/nir_inline_helpers.h b/src/compiler/nir/nir_inline_helpers.h index 1698e06271e..125dd8a537c 100644 --- a/src/compiler/nir/nir_inline_helpers.h +++ b/src/compiler/nir/nir_inline_helpers.h @@ -1,5 +1,8 @@ -static inline bool -nir_foreach_dest(nir_instr *instr, nir_foreach_dest_cb cb, void *state) +/* _nir_foreach_dest() needs to be ALWAYS_INLINE so that it can inline the + * callback if it was declared with ALWAYS_INLINE. + */ +static ALWAYS_INLINE bool +_nir_foreach_dest(nir_instr *instr, nir_foreach_dest_cb cb, void *state) { switch (instr->type) { case nir_instr_type_alu: @@ -64,6 +67,12 @@ _nir_visit_dest_indirect(nir_dest *dest, void *_state) return true; } +static inline bool +nir_foreach_dest(nir_instr *instr, nir_foreach_dest_cb cb, void *state) +{ + return _nir_foreach_dest(instr, cb, state); +} + static inline bool nir_foreach_src(nir_instr *instr, nir_foreach_src_cb cb, void *state) { @@ -151,5 +160,5 @@ nir_foreach_src(nir_instr *instr, nir_foreach_src_cb cb, void *state) _nir_visit_dest_indirect_state dest_state; dest_state.state = state; dest_state.cb = cb; - return nir_foreach_dest(instr, _nir_visit_dest_indirect, &dest_state); + return _nir_foreach_dest(instr, _nir_visit_dest_indirect, &dest_state); }