Mesa (main): clc: Only initialize LLVM once
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Apr 14 22:00:15 UTC 2022
Module: Mesa
Branch: main
Commit: 6e3b9b1b1d8f5b88ac5f0a660c9c08261490206e
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6e3b9b1b1d8f5b88ac5f0a660c9c08261490206e
Author: Jason Ekstrand <jason.ekstrand at collabora.com>
Date: Fri Apr 8 16:20:43 2022 -0500
clc: Only initialize LLVM once
Reviewed-by: Jesse Natalie <jenatali at microsoft.com>
Reviewed-by: Icecream95 <ixn at disroot.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15937>
---
src/compiler/clc/clc_helpers.cpp | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/compiler/clc/clc_helpers.cpp b/src/compiler/clc/clc_helpers.cpp
index 73d34ddab72..1a7f0c19f6a 100644
--- a/src/compiler/clc/clc_helpers.cpp
+++ b/src/compiler/clc/clc_helpers.cpp
@@ -24,6 +24,7 @@
// OTHER DEALINGS IN THE SOFTWARE.
#include <sstream>
+#include <mutex>
#include <llvm/ADT/ArrayRef.h>
#include <llvm/IR/DiagnosticPrinter.h>
@@ -1148,7 +1149,7 @@ clc_free_spirv_binary(struct clc_binary *spvbin)
}
void
-clc_initialize_llvm(void)
+initialize_llvm_once(void)
{
LLVMInitializeAllTargets();
LLVMInitializeAllTargetInfos();
@@ -1156,3 +1157,12 @@ clc_initialize_llvm(void)
LLVMInitializeAllAsmParsers();
LLVMInitializeAllAsmPrinters();
}
+
+std::once_flag initialize_llvm_once_flag;
+
+void
+clc_initialize_llvm(void)
+{
+ std::call_once(initialize_llvm_once_flag,
+ []() { initialize_llvm_once(); });
+}
More information about the mesa-commit
mailing list