Module: Mesa
Branch: master
Commit: ff330055e989803fa05c2d5c8e1a4c08b52a55fd
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ff330055e989803fa05c2d5c8e1a4c08b52a55fd

Author: Marek Olšák <[email protected]>
Date:   Wed Jul  4 01:28:17 2018 -0400

radeonsi: use ac_compile_module_to_binary to reduce compile times

Compile times of simple shaders are reduced by ~20%.
Compile times of prologs and epilogs are reduced by up to 40%.

Reviewed-by: Dave Airlie <[email protected]>

---

 src/gallium/drivers/radeonsi/si_pipe.c             |  2 ++
 .../drivers/radeonsi/si_shader_tgsi_setup.c        | 33 ++--------------------
 2 files changed, 4 insertions(+), 31 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_pipe.c 
b/src/gallium/drivers/radeonsi/si_pipe.c
index 35ddb114d0..86a95a0da0 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -116,10 +116,12 @@ static void si_init_compiler(struct si_screen *sscreen,
 
        ac_init_llvm_once();
        ac_init_llvm_compiler(compiler, true, sscreen->info.family, tm_options);
+       compiler->passes = ac_create_llvm_passes(compiler->tm);
 }
 
 static void si_destroy_compiler(struct ac_llvm_compiler *compiler)
 {
+       ac_destroy_llvm_passes(compiler->passes);
        ac_destroy_llvm_compiler(compiler);
 }
 
diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c 
b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c
index 566d3a8eb6..6c1e18ff81 100644
--- a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c
+++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c
@@ -85,12 +85,7 @@ unsigned si_llvm_compile(LLVMModuleRef M, struct 
ac_shader_binary *binary,
                         struct pipe_debug_callback *debug)
 {
        struct si_llvm_diagnostics diag;
-       char *err;
        LLVMContextRef llvm_ctx;
-       LLVMMemoryBufferRef out_buffer;
-       unsigned buffer_size;
-       const char *buffer_data;
-       LLVMBool mem_err;
 
        diag.debug = debug;
        diag.retval = 0;
@@ -100,34 +95,10 @@ unsigned si_llvm_compile(LLVMModuleRef M, struct 
ac_shader_binary *binary,
 
        LLVMContextSetDiagnosticHandler(llvm_ctx, si_diagnostic_handler, &diag);
 
-       /* Compile IR*/
-       mem_err = LLVMTargetMachineEmitToMemoryBuffer(compiler->tm, M,
-                                                     LLVMObjectFile, &err,
-                                                     &out_buffer);
-
-       /* Process Errors/Warnings */
-       if (mem_err) {
-               fprintf(stderr, "%s: %s", __FUNCTION__, err);
-               pipe_debug_message(debug, SHADER_INFO,
-                                  "LLVM emit error: %s", err);
-               FREE(err);
+       /* Compile IR. */
+       if (!ac_compile_module_to_binary(compiler->passes, M, binary))
                diag.retval = 1;
-               goto out;
-       }
-
-       /* Extract Shader Code*/
-       buffer_size = LLVMGetBufferSize(out_buffer);
-       buffer_data = LLVMGetBufferStart(out_buffer);
-
-       if (!ac_elf_read(buffer_data, buffer_size, binary)) {
-               fprintf(stderr, "radeonsi: cannot read an ELF shader binary\n");
-               diag.retval = 1;
-       }
-
-       /* Clean up */
-       LLVMDisposeMemoryBuffer(out_buffer);
 
-out:
        if (diag.retval != 0)
                pipe_debug_message(debug, SHADER_INFO, "LLVM compile failed");
        return diag.retval;

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to