From: Marek Olšák Date: Wed, 15 Jan 2020 23:54:39 +0000 (-0500) Subject: radeonsi: make si_compile_llvm return bool X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=be772182e002fc4add5654fa84cfd940c0b1e773;p=mesa.git radeonsi: make si_compile_llvm return bool Reviewed-by: Timothy Arceri Part-of: --- diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index b3739533a9c..d86b061c35f 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -1723,7 +1723,6 @@ int si_compile_shader(struct si_screen *sscreen, struct si_shader_context ctx; bool free_nir; struct nir_shader *nir = get_nir_shader(sel, &free_nir); - int r = -1; /* Dump NIR before doing NIR->LLVM conversion in case the * conversion fails. */ @@ -1973,15 +1972,16 @@ int si_compile_shader(struct si_screen *sscreen, LLVMPointerTypeKind); /* Compile to bytecode. */ - r = si_compile_llvm(sscreen, &shader->binary, &shader->config, compiler, - &ctx.ac, debug, ctx.type, si_get_shader_name(shader), - si_should_optimize_less(compiler, shader->selector)); - si_llvm_dispose(&ctx); - if (r) { + if (!si_compile_llvm(sscreen, &shader->binary, &shader->config, compiler, + &ctx.ac, debug, ctx.type, si_get_shader_name(shader), + si_should_optimize_less(compiler, shader->selector))) { + si_llvm_dispose(&ctx); fprintf(stderr, "LLVM failed to compile shader\n"); - return r; + return -1; } + si_llvm_dispose(&ctx); + /* Validate SGPR and VGPR usage for compute to detect compiler bugs. * LLVM 3.9svn has this bug. */ @@ -2110,8 +2110,8 @@ si_get_shader_part(struct si_screen *sscreen, /* Compile. */ si_llvm_optimize_module(&ctx); - if (si_compile_llvm(sscreen, &result->binary, &result->config, compiler, - &ctx.ac, debug, ctx.type, name, false)) { + if (!si_compile_llvm(sscreen, &result->binary, &result->config, compiler, + &ctx.ac, debug, ctx.type, name, false)) { FREE(result); result = NULL; goto out; diff --git a/src/gallium/drivers/radeonsi/si_shader_internal.h b/src/gallium/drivers/radeonsi/si_shader_internal.h index 542466ee205..4f351f55cad 100644 --- a/src/gallium/drivers/radeonsi/si_shader_internal.h +++ b/src/gallium/drivers/radeonsi/si_shader_internal.h @@ -232,15 +232,15 @@ void gfx10_ngg_gs_emit_epilogue(struct si_shader_context *ctx); void gfx10_ngg_calculate_subgroup_info(struct si_shader *shader); /* si_shader_llvm.c */ -int si_compile_llvm(struct si_screen *sscreen, - struct si_shader_binary *binary, - struct ac_shader_config *conf, - struct ac_llvm_compiler *compiler, - struct ac_llvm_context *ac, - struct pipe_debug_callback *debug, - enum pipe_shader_type shader_type, - const char *name, - bool less_optimized); +bool si_compile_llvm(struct si_screen *sscreen, + struct si_shader_binary *binary, + struct ac_shader_config *conf, + struct ac_llvm_compiler *compiler, + struct ac_llvm_context *ac, + struct pipe_debug_callback *debug, + enum pipe_shader_type shader_type, + const char *name, + bool less_optimized); void si_llvm_context_init(struct si_shader_context *ctx, struct si_screen *sscreen, struct ac_llvm_compiler *compiler, diff --git a/src/gallium/drivers/radeonsi/si_shader_llvm.c b/src/gallium/drivers/radeonsi/si_shader_llvm.c index 4ddcbccfac0..0e74a3369f2 100644 --- a/src/gallium/drivers/radeonsi/si_shader_llvm.c +++ b/src/gallium/drivers/radeonsi/si_shader_llvm.c @@ -68,15 +68,15 @@ static void si_diagnostic_handler(LLVMDiagnosticInfoRef di, void *context) LLVMDisposeMessage(description); } -int si_compile_llvm(struct si_screen *sscreen, - struct si_shader_binary *binary, - struct ac_shader_config *conf, - struct ac_llvm_compiler *compiler, - struct ac_llvm_context *ac, - struct pipe_debug_callback *debug, - enum pipe_shader_type shader_type, - const char *name, - bool less_optimized) +bool si_compile_llvm(struct si_screen *sscreen, + struct si_shader_binary *binary, + struct ac_shader_config *conf, + struct ac_llvm_compiler *compiler, + struct ac_llvm_context *ac, + struct pipe_debug_callback *debug, + enum pipe_shader_type shader_type, + const char *name, + bool less_optimized) { unsigned count = p_atomic_inc_return(&sscreen->num_compilations); @@ -114,7 +114,7 @@ int si_compile_llvm(struct si_screen *sscreen, if (diag.retval != 0) { pipe_debug_message(debug, SHADER_INFO, "LLVM compilation failed"); - return diag.retval; + return false; } } @@ -126,12 +126,12 @@ int si_compile_llvm(struct si_screen *sscreen, .num_parts = 1, .elf_ptrs = &binary->elf_buffer, .elf_sizes = &binary->elf_size })) - return -1; + return false; bool ok = ac_rtld_read_config(&rtld, conf); ac_rtld_close(&rtld); if (!ok) - return -1; + return false; /* Enable 64-bit and 16-bit denormals, because there is no performance * cost. @@ -147,7 +147,7 @@ int si_compile_llvm(struct si_screen *sscreen, */ conf->float_mode |= V_00B028_FP_64_DENORMS; - return 0; + return true; } void si_llvm_context_init(struct si_shader_context *ctx, diff --git a/src/gallium/drivers/radeonsi/si_shader_llvm_gs.c b/src/gallium/drivers/radeonsi/si_shader_llvm_gs.c index de3a5cb95a2..ac734d0924b 100644 --- a/src/gallium/drivers/radeonsi/si_shader_llvm_gs.c +++ b/src/gallium/drivers/radeonsi/si_shader_llvm_gs.c @@ -625,7 +625,7 @@ si_generate_gs_copy_shader(struct si_screen *sscreen, if (si_compile_llvm(sscreen, &ctx.shader->binary, &ctx.shader->config, ctx.compiler, &ctx.ac, debug, PIPE_SHADER_GEOMETRY, - "GS Copy Shader", false) == 0) { + "GS Copy Shader", false)) { if (si_can_dump_shader(sscreen, PIPE_SHADER_GEOMETRY)) fprintf(stderr, "GS Copy Shader:\n"); si_shader_dump(sscreen, ctx.shader, debug, stderr, true);