Module: Mesa
Branch: master
Commit: f66a7240f9f2d231c105ed0d79c10ac8d9780874
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f66a7240f9f2d231c105ed0d79c10ac8d9780874

Author: Rhys Perry <[email protected]>
Date:   Fri Feb 26 09:08:56 2021 +0000

nir: fix build at -O1

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 <[email protected]>
Acked-by: Jason Ekstrand <[email protected]>
Reviewed-by: Daniel Schürmann <[email protected]>
Reviewed-by: Witold Baryluk <[email protected]>
Fixes: 336bcbacd05 ("nir: inline nir_foreach_{src,dest}")
Tested-by: Witold Baryluk <[email protected]>
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4353
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9301>

---

 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);
 }

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to