Mesa (master): nir: properly clear the entry sources in copy_prop_vars

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Dec 19 16:37:26 UTC 2018


Module: Mesa
Branch: master
Commit: 0ddc911f4d83a3c698ea02696e1b8706b2cce381
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0ddc911f4d83a3c698ea02696e1b8706b2cce381

Author: Caio Marcelo de Oliveira Filho <caio.oliveira at intel.com>
Date:   Fri Dec 14 22:19:24 2018 -0800

nir: properly clear the entry sources in copy_prop_vars

When updating a copy entry source value from a "non-SSA" (the data
come from a copy instruction) to a "SSA" (the data or parts of it come
from SSA values), it was possible to hold invalid data in ssa[0]
depending on the writemask.  Because the union, ssa[0] could contain a
pointer to a nir_deref_instr left-over from previous non-SSA usage.

Change code to clean up the array before use to avoid invalid data
around.

Fixes: 62332d139c8 "nir: Add a local variable-based copy propagation pass"
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>

---

 src/compiler/nir/nir_opt_copy_prop_vars.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/compiler/nir/nir_opt_copy_prop_vars.c b/src/compiler/nir/nir_opt_copy_prop_vars.c
index a540e01529..ce106be8de 100644
--- a/src/compiler/nir/nir_opt_copy_prop_vars.c
+++ b/src/compiler/nir/nir_opt_copy_prop_vars.c
@@ -348,6 +348,9 @@ store_to_entry(struct copy_prop_var_state *state, struct copy_entry *entry,
                const struct value *value, unsigned write_mask)
 {
    if (value->is_ssa) {
+      /* Clear src if it was being used as non-SSA. */
+      if (!entry->src.is_ssa)
+         memset(entry->src.ssa, 0, sizeof(entry->src.ssa));
       entry->src.is_ssa = true;
       /* Only overwrite the written components */
       for (unsigned i = 0; i < 4; i++) {




More information about the mesa-commit mailing list