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 <pendingchaos02@gmail.com>
Acked-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Reviewed-by: Witold Baryluk <witold.baryluk@gmail.com>
Fixes: 336bcbacd0 ("nir: inline nir_foreach_{src,dest}")
Tested-by: Witold Baryluk <witold.baryluk@gmail.com>
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4353
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9301>
This commit is contained in:
Rhys Perry 2021-02-26 09:08:56 +00:00 committed by Marge Bot
parent 512d281853
commit f66a7240f9

View file

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