nir: Add a nir_foreach_function_temp_variable helper
[mesa.git] / src / compiler / nir / nir_opt_large_constants.c
index 7ed26f5112785b4eced2093b7a16dd58e462bf04..2575407ca0b5b4e3bb72b745a1a1e2f30e364cd2 100644 (file)
@@ -179,11 +179,13 @@ nir_opt_large_constants(nir_shader *shader,
    unsigned num_locals = exec_list_length(&impl->locals);
    nir_index_vars(shader, impl, nir_var_function_temp);
 
-   if (num_locals == 0)
+   if (num_locals == 0) {
+      nir_shader_preserve_all_metadata(shader);
       return false;
+   }
 
    struct var_info *var_infos = ralloc_array(NULL, struct var_info, num_locals);
-   nir_foreach_variable(var, &impl->locals) {
+   nir_foreach_function_temp_variable(var, impl) {
       var_infos[var->index] = (struct var_info) {
          .var = var,
          .is_constant = true,
@@ -302,6 +304,7 @@ nir_opt_large_constants(nir_shader *shader,
    }
 
    if (shader->constant_data_size == 0) {
+      nir_shader_preserve_all_metadata(shader);
       ralloc_free(var_infos);
       return false;
    }