diff options
author | Connor Abbott <[email protected]> | 2017-01-14 18:08:11 -0500 |
---|---|---|
committer | Connor Abbott <[email protected]> | 2017-01-14 18:18:17 -0500 |
commit | c9b74f3f0306a3305ad62644a7c7ef1e4a3f19f1 (patch) | |
tree | 9ba956776cec33f32e037852be1e630f400a8070 | |
parent | bf8e1f9e7b26acecab1fc63a526ce3d10eae4c61 (diff) |
nir/gcm: fix a bug with metadata handling
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 <[email protected]>
Reviewed-by: Jason Ekstrand <[email protected]>
-rw-r--r-- | src/compiler/nir/nir_opt_gcm.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/compiler/nir/nir_opt_gcm.c b/src/compiler/nir/nir_opt_gcm.c index cff2315da30..879a77a884b 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) { |