diff --git a/src/compiler/clc/clc_helpers.cpp b/src/compiler/clc/clc_helpers.cpp index ddc6a40f29e..189152c5849 100644 --- a/src/compiler/clc/clc_helpers.cpp +++ b/src/compiler/clc/clc_helpers.cpp @@ -745,10 +745,7 @@ static std::pair, std::unique_ptr> clc_compile_to_llvm_module(const struct clc_compile_args *args, const struct clc_logger *logger) { - LLVMInitializeAllTargets(); - LLVMInitializeAllTargetInfos(); - LLVMInitializeAllTargetMCs(); - LLVMInitializeAllAsmPrinters(); + clc_initialize_llvm(); std::string log; std::unique_ptr llvm_ctx { new LLVMContext }; @@ -991,10 +988,7 @@ clc_spir_to_spirv(const struct clc_binary *in_spir, const struct clc_logger *logger, struct clc_binary *out_spirv) { - LLVMInitializeAllTargets(); - LLVMInitializeAllTargetInfos(); - LLVMInitializeAllTargetMCs(); - LLVMInitializeAllAsmPrinters(); + clc_initialize_llvm(); std::unique_ptr llvm_ctx{ new LLVMContext }; ::llvm::StringRef spir_ref(static_cast(in_spir->data), in_spir->size); @@ -1152,3 +1146,12 @@ clc_free_spirv_binary(struct clc_binary *spvbin) { free(spvbin->data); } + +void +clc_initialize_llvm(void) +{ + LLVMInitializeAllTargets(); + LLVMInitializeAllTargetInfos(); + LLVMInitializeAllTargetMCs(); + LLVMInitializeAllAsmPrinters(); +} diff --git a/src/compiler/clc/clc_helpers.h b/src/compiler/clc/clc_helpers.h index cbad142efeb..0ad0990f074 100644 --- a/src/compiler/clc/clc_helpers.h +++ b/src/compiler/clc/clc_helpers.h @@ -38,6 +38,9 @@ extern "C" { #endif +void +clc_initialize_llvm(void); + bool clc_spirv_get_kernels_info(const struct clc_binary *spvbin, const struct clc_kernel_info **kernels,