From: Nicolai Hähnle Date: Thu, 27 Oct 2016 15:22:10 +0000 (+0200) Subject: radeonsi: free data structures when shader compiles fail X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8db9d915cd771985609370f1d3bdda63eba687b2;p=mesa.git radeonsi: free data structures when shader compiles fail Reviewed-by: Marek Olšák --- diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index 6ae63c8a164..5a0153c5a32 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -6783,8 +6783,10 @@ int si_compile_tgsi_shader(struct si_screen *sscreen, bld_base = &ctx.soa.bld_base; ctx.load_system_value = declare_system_value; - if (!si_compile_tgsi_main(&ctx, shader)) - goto out; + if (!si_compile_tgsi_main(&ctx, shader)) { + si_llvm_dispose(&ctx); + return -1; + } mod = bld_base->base.gallivm->module; @@ -6802,13 +6804,12 @@ int si_compile_tgsi_shader(struct si_screen *sscreen, /* Compile to bytecode. */ r = si_compile_llvm(sscreen, &shader->binary, &shader->config, tm, mod, debug, ctx.type, "TGSI shader"); + si_llvm_dispose(&ctx); if (r) { fprintf(stderr, "LLVM failed to compile shader\n"); - goto out; + return r; } - si_llvm_dispose(&ctx); - /* Validate SGPR and VGPR usage for compute to detect compiler bugs. * LLVM 3.9svn has this bug. */ @@ -6898,17 +6899,16 @@ int si_compile_tgsi_shader(struct si_screen *sscreen, shader->gs_copy_shader = CALLOC_STRUCT(si_shader); shader->gs_copy_shader->selector = shader->selector; ctx.shader = shader->gs_copy_shader; - if ((r = si_generate_gs_copy_shader(sscreen, &ctx, - shader, debug))) { + r = si_generate_gs_copy_shader(sscreen, &ctx, + shader, debug); + if (r) { free(shader->gs_copy_shader); shader->gs_copy_shader = NULL; - goto out; + return r; } } - r = 0; -out: - return r; + return 0; } /**