radeonsi: make si_compile_llvm return bool
authorMarek Olšák <marek.olsak@amd.com>
Wed, 15 Jan 2020 23:54:39 +0000 (18:54 -0500)
committerMarge Bot <eric+marge@anholt.net>
Thu, 23 Jan 2020 19:10:21 +0000 (19:10 +0000)
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3421>

src/gallium/drivers/radeonsi/si_shader.c
src/gallium/drivers/radeonsi/si_shader_internal.h
src/gallium/drivers/radeonsi/si_shader_llvm.c
src/gallium/drivers/radeonsi/si_shader_llvm_gs.c

index b3739533a9c096b5b780af079ecc4a21f8e49378..d86b061c35f56ecf9063263dfe6cd42e631f9697 100644 (file)
@@ -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;
index 542466ee2056c5232022dd3fc584c5b094eb4e86..4f351f55cad0de3b91e5571f737be21f0d7f98a9 100644 (file)
@@ -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,
index 4ddcbccfac0a5767bc2042881c24e647eaeac286..0e74a3369f286284fef62d691032d8dc183c7f23 100644 (file)
@@ -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,
index de3a5cb95a2918f7bbc27d806bbfcdbd6fb83b1e..ac734d0924b05506b7eec9d2fefd4cab604856b2 100644 (file)
@@ -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);