fix data race in HALDispatchABI::getProcessorType (#8590)
diff --git a/iree/compiler/Codegen/LLVMCPU/ConvertToLLVM.cpp b/iree/compiler/Codegen/LLVMCPU/ConvertToLLVM.cpp
index dc74bea..12963e1 100644
--- a/iree/compiler/Codegen/LLVMCPU/ConvertToLLVM.cpp
+++ b/iree/compiler/Codegen/LLVMCPU/ConvertToLLVM.cpp
@@ -12,6 +12,7 @@
#include "iree/compiler/Dialect/Util/IR/UtilDialect.h"
#include "iree/compiler/Dialect/Util/IR/UtilOps.h"
#include "llvm/ADT/Triple.h"
+#include "llvm/Support/Mutex.h"
#include "llvm/Support/raw_ostream.h"
#include "mlir/Analysis/DataLayoutAnalysis.h"
#include "mlir/Conversion/AffineToStandard/AffineToStandard.h"
@@ -74,6 +75,8 @@
// Returns a Type representing iree_hal_processor_v0_t.
static LLVM::LLVMStructType getProcessorType(
MLIRContext *context, LLVMTypeConverter *typeConverter) {
+ static llvm::sys::Mutex mutex;
+ llvm::sys::ScopedLock lock(mutex);
auto structType =
LLVM::LLVMStructType::getIdentified(context, "iree_hal_processor_v0_t");
if (structType.isInitialized()) return structType;