summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gallium/drivers/radeonsi/si_pipe.c10
-rw-r--r--src/gallium/drivers/radeonsi/si_shader.h1
-rw-r--r--src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c7
3 files changed, 13 insertions, 5 deletions
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c
index dbfb9c8fdea..19b570e569e 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -29,6 +29,7 @@
#include "sid.h"
#include "radeon/radeon_uvd.h"
+#include "gallivm/lp_bld_misc.h"
#include "util/disk_cache.h"
#include "util/hash_table.h"
#include "util/u_log.h"
@@ -113,10 +114,19 @@ static void si_init_compiler(struct si_screen *sscreen,
compiler->tm = ac_create_target_machine(sscreen->info.family,
tm_options, &compiler->triple);
+ if (!compiler->tm)
+ return;
+
+ compiler->target_library_info =
+ gallivm_create_target_library_info(compiler->triple);
+ if (!compiler->target_library_info)
+ return;
}
static void si_destroy_compiler(struct si_compiler *compiler)
{
+ if (compiler->target_library_info)
+ gallivm_dispose_target_library_info(compiler->target_library_info);
if (compiler->tm)
LLVMDisposeTargetMachine(compiler->tm);
}
diff --git a/src/gallium/drivers/radeonsi/si_shader.h b/src/gallium/drivers/radeonsi/si_shader.h
index e6205a204c1..8761bc7e7c9 100644
--- a/src/gallium/drivers/radeonsi/si_shader.h
+++ b/src/gallium/drivers/radeonsi/si_shader.h
@@ -315,6 +315,7 @@ struct si_shader;
struct si_compiler {
LLVMTargetMachineRef tm;
const char *triple;
+ LLVMTargetLibraryInfoRef target_library_info;
};
/* State of the context creating the shader object. */
diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c
index f354417b89e..86366f4063c 100644
--- a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c
+++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c
@@ -1213,7 +1213,6 @@ void si_llvm_create_func(struct si_shader_context *ctx,
void si_llvm_optimize_module(struct si_shader_context *ctx)
{
struct gallivm_state *gallivm = &ctx->gallivm;
- LLVMTargetLibraryInfoRef target_library_info;
/* Dump LLVM IR before any optimization passes */
if (ctx->screen->debug_flags & DBG(PREOPT_IR) &&
@@ -1223,9 +1222,8 @@ void si_llvm_optimize_module(struct si_shader_context *ctx)
/* Create the pass manager */
gallivm->passmgr = LLVMCreatePassManager();
- target_library_info =
- gallivm_create_target_library_info(ctx->compiler->triple);
- LLVMAddTargetLibraryInfo(target_library_info, gallivm->passmgr);
+ LLVMAddTargetLibraryInfo(ctx->compiler->target_library_info,
+ gallivm->passmgr);
if (si_extra_shader_checks(ctx->screen, ctx->type))
LLVMAddVerifierPass(gallivm->passmgr);
@@ -1249,7 +1247,6 @@ void si_llvm_optimize_module(struct si_shader_context *ctx)
LLVMDisposeBuilder(ctx->ac.builder);
LLVMDisposePassManager(gallivm->passmgr);
- gallivm_dispose_target_library_info(target_library_info);
}
void si_llvm_dispose(struct si_shader_context *ctx)