From 8db9d915cd771985609370f1d3bdda63eba687b2 Mon Sep 17 00:00:00 2001 From: Nicolai Hähnle Date: Thu, 27 Oct 2016 17:22:10 +0200 Subject: radeonsi: free data structures when shader compiles fail MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Marek Olšák --- src/gallium/drivers/radeonsi/si_shader.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src') 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; } /** -- cgit v1.2.3