nir: Add a lowering pass to split 64bit phis
[mesa.git] / src / compiler / nir / nir_sweep.c
index b22f0f5656937fec6bd057776fd1c5e347f70608..e2b70f5f76710bc627fbf34e9eacfa0ce5bc6ce4 100644 (file)
@@ -63,7 +63,16 @@ sweep_block(nir_shader *nir, nir_block *block)
 {
    ralloc_steal(nir, block);
 
-   nir_foreach_instr(block, instr) {
+   /* sweep_impl will mark all metadata invalid.  We can safely release all of
+    * this here.
+    */
+   ralloc_free(block->live_in);
+   block->live_in = NULL;
+
+   ralloc_free(block->live_out);
+   block->live_out = NULL;
+
+   nir_foreach_instr(instr, block) {
       ralloc_steal(nir, instr);
 
       nir_foreach_src(instr, sweep_src_indirect, nir);
@@ -118,10 +127,6 @@ sweep_impl(nir_shader *nir, nir_function_impl *impl)
 {
    ralloc_steal(nir, impl);
 
-   ralloc_steal(nir, impl->params);
-   for (unsigned i = 0; i < impl->num_params; i++)
-      ralloc_steal(nir, impl->params[i]);
-   ralloc_steal(nir, impl->return_var);
    steal_list(nir, nir_variable, &impl->locals);
    steal_list(nir, nir_register, &impl->registers);
 
@@ -158,19 +163,15 @@ nir_sweep(nir_shader *nir)
       ralloc_steal(nir, (char *)nir->info.label);
 
    /* Variables and registers are not dead.  Steal them back. */
-   steal_list(nir, nir_variable, &nir->uniforms);
-   steal_list(nir, nir_variable, &nir->inputs);
-   steal_list(nir, nir_variable, &nir->outputs);
-   steal_list(nir, nir_variable, &nir->shared);
-   steal_list(nir, nir_variable, &nir->globals);
-   steal_list(nir, nir_variable, &nir->system_values);
-   steal_list(nir, nir_register, &nir->registers);
+   steal_list(nir, nir_variable, &nir->variables);
 
    /* Recurse into functions, stealing their contents back. */
    foreach_list_typed(nir_function, func, node, &nir->functions) {
       sweep_function(nir, func);
    }
 
+   ralloc_steal(nir, nir->constant_data);
+
    /* Free everything we didn't steal back. */
    ralloc_free(rubbish);
 }