1 |
From 3af043858503c1ce066989f9531e95332bbf1bc0 Mon Sep 17 00:00:00 2001 |
2 |
From: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com> |
3 |
Date: Fri, 14 Dec 2018 22:19:24 -0800 |
4 |
Subject: [PATCH 30/78] nir: properly clear the entry sources in copy_prop_vars |
5 |
|
6 |
When updating a copy entry source value from a "non-SSA" (the data |
7 |
come from a copy instruction) to a "SSA" (the data or parts of it come |
8 |
from SSA values), it was possible to hold invalid data in ssa[0] |
9 |
depending on the writemask. Because the union, ssa[0] could contain a |
10 |
pointer to a nir_deref_instr left-over from previous non-SSA usage. |
11 |
|
12 |
Change code to clean up the array before use to avoid invalid data |
13 |
around. |
14 |
|
15 |
Fixes: 62332d139c8 "nir: Add a local variable-based copy propagation pass" |
16 |
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> |
17 |
(cherry picked from commit 0ddc911f4d83a3c698ea02696e1b8706b2cce381) |
18 |
--- |
19 |
src/compiler/nir/nir_opt_copy_prop_vars.c | 3 +++ |
20 |
1 file changed, 3 insertions(+) |
21 |
|
22 |
diff --git a/src/compiler/nir/nir_opt_copy_prop_vars.c b/src/compiler/nir/nir_opt_copy_prop_vars.c |
23 |
index 7a21ad56c7..1e6158bf51 100644 |
24 |
--- a/src/compiler/nir/nir_opt_copy_prop_vars.c |
25 |
+++ b/src/compiler/nir/nir_opt_copy_prop_vars.c |
26 |
@@ -337,6 +337,9 @@ store_to_entry(struct copy_prop_var_state *state, struct copy_entry *entry, |
27 |
const struct value *value, unsigned write_mask) |
28 |
{ |
29 |
if (value->is_ssa) { |
30 |
+ /* Clear src if it was being used as non-SSA. */ |
31 |
+ if (!entry->src.is_ssa) |
32 |
+ memset(entry->src.ssa, 0, sizeof(entry->src.ssa)); |
33 |
entry->src.is_ssa = true; |
34 |
/* Only overwrite the written components */ |
35 |
for (unsigned i = 0; i < 4; i++) { |
36 |
-- |
37 |
2.20.1 |
38 |
|