spirv: Don't remove dead variables in `create_library` mode

The issues fixed by the removal happen when a module has multiple
entry points and conflicting global variables.  Neither conditions are
expected in a library.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8786>
This commit is contained in:
Caio Marcelo de Oliveira Filho 2021-01-21 02:35:43 -08:00 committed by Marge Bot
parent fd44bcf9a8
commit a0d73ca65c
1 changed files with 10 additions and 8 deletions

View File

@ -5976,14 +5976,16 @@ spirv_to_nir(const uint32_t *words, size_t word_count,
* initializers on outputs so nir_remove_dead_variables sees that they're
* written to.
*/
nir_lower_variable_initializers(b->shader, nir_var_shader_out |
nir_var_system_value);
const nir_remove_dead_variables_options dead_opts = {
.can_remove_var = can_remove,
.can_remove_var_data = b->vars_used_indirectly,
};
nir_remove_dead_variables(b->shader, ~nir_var_function_temp,
b->vars_used_indirectly ? &dead_opts : NULL);
if (!options->create_library) {
nir_lower_variable_initializers(b->shader, nir_var_shader_out |
nir_var_system_value);
const nir_remove_dead_variables_options dead_opts = {
.can_remove_var = can_remove,
.can_remove_var_data = b->vars_used_indirectly,
};
nir_remove_dead_variables(b->shader, ~nir_var_function_temp,
b->vars_used_indirectly ? &dead_opts : NULL);
}
/* We sometimes generate bogus derefs that, while never used, give the
* validator a bit of heartburn. Run dead code to get rid of them.