[Mesa-dev] [PATCH 08/31] radeonsi: free data structures when shader compiles fail
Nicolai Hähnle
nhaehnle at gmail.com
Mon Oct 31 22:10:55 UTC 2016
From: Nicolai Hähnle <nicolai.haehnle at amd.com>
---
src/gallium/drivers/radeonsi/si_shader.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index 6ae63c8..5a0153c 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -6776,46 +6776,47 @@ int si_compile_tgsi_shader(struct si_screen *sscreen,
ctx.is_monolithic = is_monolithic;
memset(shader->info.vs_output_param_offset, 0xff,
sizeof(shader->info.vs_output_param_offset));
shader->info.uses_instanceid = sel->info.uses_instanceid;
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;
/* Dump LLVM IR before any optimization passes */
if (sscreen->b.debug_flags & DBG_PREOPT_IR &&
r600_can_dump_shader(&sscreen->b, ctx.type))
LLVMDumpModule(mod);
si_llvm_finalize_module(&ctx,
r600_extra_shader_checks(&sscreen->b, ctx.type));
/* Post-optimization transformations. */
si_eliminate_const_vs_outputs(&ctx);
/* 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.
*/
if (sel->type == PIPE_SHADER_COMPUTE) {
unsigned *props = sel->info.properties;
unsigned wave_size = 64;
unsigned max_vgprs = 256;
unsigned max_sgprs = sscreen->b.chip_class >= VI ? 800 : 512;
unsigned max_sgprs_per_wave = 128;
unsigned max_block_threads;
@@ -6891,31 +6892,30 @@ int si_compile_tgsi_shader(struct si_screen *sscreen,
if (G_0286CC_SAMPLE_COVERAGE_ENA(shader->config.spi_ps_input_addr))
shader->info.num_input_vgprs += 1;
if (G_0286CC_POS_FIXED_PT_ENA(shader->config.spi_ps_input_addr))
shader->info.num_input_vgprs += 1;
}
if (ctx.type == PIPE_SHADER_GEOMETRY) {
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;
}
/**
* Create, compile and return a shader part (prolog or epilog).
*
* \param sscreen screen
* \param list list of shader parts of the same category
* \param key shader part key
* \param tm LLVM target machine
* \param debug debug callback
--
2.7.4
More information about the mesa-dev
mailing list