nir: fix nir_sweep for printf
authorKarol Herbst <kherbst@redhat.com>
Sat, 19 Mar 2022 15:36:46 +0000 (16:36 +0100)
committerMarge Bot <emma+marge@anholt.net>
Mon, 21 Mar 2022 13:23:04 +0000 (13:23 +0000)
I hit a memory corruption trying to implement printf for Rusticl

Signed-off-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15474>

src/compiler/nir/nir_sweep.c

index 0c5c71a..d931556 100644 (file)
@@ -163,6 +163,11 @@ nir_sweep(nir_shader *nir)
    assert(list_is_empty(&instr_gc_list));
 
    ralloc_steal(nir, nir->constant_data);
+   ralloc_steal(nir, nir->printf_info);
+   for (int i = 0; i < nir->printf_info_count; i++) {
+      ralloc_steal(nir, nir->printf_info[i].arg_sizes);
+      ralloc_steal(nir, nir->printf_info[i].strings);
+   }
 
    /* Free everything we didn't steal back. */
    ralloc_free(rubbish);