<div dir="ltr">Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jan 14, 2017 at 3:12 PM, Connor Abbott <span dir="ltr"><<a href="mailto:cwabbott0@gmail.com" target="_blank">cwabbott0@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">We were using impl->num_blocks, but that isn't guaranteed to be<br>
up-to-date until after the block_index metadata is required. If we were<br>
unlucky, this could lead to overwriting memory.<br>
<br>
Noticed by inspection.<br>
<br>
Signed-off-by: Connor Abbott <<a href="mailto:cwabbott0@gmail.com">cwabbott0@gmail.com</a>><br>
---<br>
 src/compiler/nir/nir_opt_gcm.c | 6 +++---<br>
 1 file changed, 3 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/src/compiler/nir/nir_opt_<wbr>gcm.c b/src/compiler/nir/nir_opt_<wbr>gcm.c<br>
index cff2315..879a77a 100644<br>
--- a/src/compiler/nir/nir_opt_<wbr>gcm.c<br>
+++ b/src/compiler/nir/nir_opt_<wbr>gcm.c<br>
@@ -456,6 +456,9 @@ gcm_place_instr(nir_instr *instr, struct gcm_state *state)<br>
 static bool<br>
 opt_gcm_impl(nir_function_impl *impl, bool value_number)<br>
 {<br>
+   nir_metadata_require(impl, nir_metadata_block_index |<br>
+                              nir_metadata_dominance);<br>
+<br>
    struct gcm_state state;<br>
<br>
    state.impl = impl;<br>
@@ -463,9 +466,6 @@ opt_gcm_impl(nir_function_impl *impl, bool value_number)<br>
    exec_list_make_empty(&state.<wbr>instrs);<br>
    state.blocks = rzalloc_array(NULL, struct gcm_block_info, impl->num_blocks);<br>
<br>
-   nir_metadata_require(impl, nir_metadata_block_index |<br>
-                              nir_metadata_dominance);<br>
-<br>
    gcm_build_block_info(&impl-><wbr>body, &state, 0);<br>
<br>
    nir_foreach_block(block, impl) {<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.5.5<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div>