microsoft/clc: Fix const violations from ralloc_steal
authorJesse Natalie <jenatali@microsoft.com>
Thu, 19 Nov 2020 22:44:08 +0000 (14:44 -0800)
committerMarge Bot <eric+marge@anholt.net>
Mon, 4 Jan 2021 22:05:02 +0000 (22:05 +0000)
Fixes: ff05da7f8dc ("microsoft: Add CLC frontend and kernel/compute support to DXIL converter")

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7697>

src/microsoft/clc/clc_compiler.c

index 15b1380..8cea382 100644 (file)
@@ -515,8 +515,8 @@ clc_context_new(const struct clc_logger *logger, const struct clc_context_option
    if (options && options->optimize)
       clc_context_optimize(s);
 
+   ralloc_steal(ctx, s);
    ctx->libclc_nir = s;
-   ralloc_steal(ctx, ctx->libclc_nir);
 
    return ctx;
 }
@@ -559,13 +559,14 @@ struct clc_context *
    struct blob_reader tmp;
    blob_reader_init(&tmp, serialized, serialized_size);
 
-   ctx->libclc_nir = nir_deserialize(NULL, libclc_nir_options, &tmp);
-   if (!ctx->libclc_nir) {
-      free(ctx);
+   nir_shader *s = nir_deserialize(NULL, libclc_nir_options, &tmp);
+   if (!s) {
+      ralloc_free(ctx);
       return NULL;
    }
 
-   ralloc_steal(ctx, ctx->libclc_nir);
+   ralloc_steal(ctx, s);
+   ctx->libclc_nir = s;
 
    return ctx;
 }