[Mesa-dev] [PATCH 04/12] nir/instr_set: Fix nir_instrs_equal for derefs

Thomas Helland thomashelland90 at gmail.com
Thu Jul 26 16:45:15 UTC 2018


This is:
Reviewed-by: Thomas Helland<thomashelland90 at gmail.com>

2018-07-26 18:00 GMT+02:00 Jason Ekstrand <jason at jlekstrand.net>:
> We weren't returning at the end of the nir_isntr_type_deref case in
> nir_instrs_equal and it was falling through to the default of false.
> While we're at it, make the default unreachable because all statements
> in the switch now have their own returns.  Had we done that before, we
> would have caught this bug a long time ago.
>
> Fixes: 19a4662a540a8c94 "nir: Add a deref instruction type"
> ---
>  src/compiler/nir/nir_instr_set.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/compiler/nir/nir_instr_set.c b/src/compiler/nir/nir_instr_set.c
> index 42aa61808ac..19771fcd9dd 100644
> --- a/src/compiler/nir/nir_instr_set.c
> +++ b/src/compiler/nir/nir_instr_set.c
> @@ -357,7 +357,7 @@ nir_instrs_equal(const nir_instr *instr1, const nir_instr *instr2)
>        default:
>           unreachable("Invalid instruction deref type");
>        }
> -      break;
> +      return true;
>     }
>     case nir_instr_type_tex: {
>        nir_tex_instr *tex1 = nir_instr_as_tex(instr1);
> @@ -460,7 +460,7 @@ nir_instrs_equal(const nir_instr *instr1, const nir_instr *instr2)
>        unreachable("Invalid instruction type");
>     }
>
> -   return false;
> +   unreachable("All cases in the above switch should return");
>  }
>
>  static bool
> --
> 2.17.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list