nir: Handle incomplete derefs in split_struct_vars

In split_var_list_structs where we initalize the splitting, we already
use get_complex_used_vars to avoid splitting any variables that have a
complex use.  However, we weren't actually handling the complex uses
properly in the case where we can't actually find the variable.

Fixes: f1cb3348f1 "nir/split_vars: Properly bail in the presence of ..."
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6332>
(cherry picked from commit 5664713d7b)
This commit is contained in:
Jason Ekstrand 2020-09-29 10:30:52 -05:00 committed by Dylan Baker
parent 194d070040
commit 8564e7da36
2 changed files with 9 additions and 1 deletions

View file

@ -4711,7 +4711,7 @@
"description": "nir: Handle incomplete derefs in split_struct_vars", "description": "nir: Handle incomplete derefs in split_struct_vars",
"nominated": true, "nominated": true,
"nomination_type": 1, "nomination_type": 1,
"resolution": 0, "resolution": 1,
"master_sha": null, "master_sha": null,
"because_sha": "f1cb3348f18a9b679925ee537091e52749e9f6da" "because_sha": "f1cb3348f18a9b679925ee537091e52749e9f6da"
}, },

View file

@ -232,6 +232,14 @@ split_struct_derefs_impl(nir_function_impl *impl,
continue; continue;
nir_variable *base_var = nir_deref_instr_get_variable(deref); nir_variable *base_var = nir_deref_instr_get_variable(deref);
/* If we can't chase back to the variable, then we're a complex use.
* This should have been detected by get_complex_used_vars() and the
* variable should not have been split. However, we have no way of
* knowing that here, so we just have to trust it.
*/
if (base_var == NULL)
continue;
struct hash_entry *entry = struct hash_entry *entry =
_mesa_hash_table_search(var_field_map, base_var); _mesa_hash_table_search(var_field_map, base_var);
if (!entry) if (!entry)