[Mesa-dev] [PATCH] nir/gcm: fix a bug with metadata handling
Jason Ekstrand
jason at jlekstrand.net
Sat Jan 14 23:13:24 UTC 2017
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
On Sat, Jan 14, 2017 at 3:12 PM, Connor Abbott <cwabbott0 at gmail.com> wrote:
> We were using impl->num_blocks, but that isn't guaranteed to be
> up-to-date until after the block_index metadata is required. If we were
> unlucky, this could lead to overwriting memory.
>
> Noticed by inspection.
>
> Signed-off-by: Connor Abbott <cwabbott0 at gmail.com>
> ---
> src/compiler/nir/nir_opt_gcm.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/compiler/nir/nir_opt_gcm.c b/src/compiler/nir/nir_opt_
> gcm.c
> index cff2315..879a77a 100644
> --- a/src/compiler/nir/nir_opt_gcm.c
> +++ b/src/compiler/nir/nir_opt_gcm.c
> @@ -456,6 +456,9 @@ gcm_place_instr(nir_instr *instr, struct gcm_state
> *state)
> static bool
> opt_gcm_impl(nir_function_impl *impl, bool value_number)
> {
> + nir_metadata_require(impl, nir_metadata_block_index |
> + nir_metadata_dominance);
> +
> struct gcm_state state;
>
> state.impl = impl;
> @@ -463,9 +466,6 @@ opt_gcm_impl(nir_function_impl *impl, bool
> value_number)
> exec_list_make_empty(&state.instrs);
> state.blocks = rzalloc_array(NULL, struct gcm_block_info,
> impl->num_blocks);
>
> - nir_metadata_require(impl, nir_metadata_block_index |
> - nir_metadata_dominance);
> -
> gcm_build_block_info(&impl->body, &state, 0);
>
> nir_foreach_block(block, impl) {
> --
> 2.5.5
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170114/33814130/attachment.html>
More information about the mesa-dev
mailing list