diff --git a/lib/polygeist/Passes/ParallelLower.cpp b/lib/polygeist/Passes/ParallelLower.cpp index b90d1c383675..0dd51f2064ef 100644 --- a/lib/polygeist/Passes/ParallelLower.cpp +++ b/lib/polygeist/Passes/ParallelLower.cpp @@ -28,6 +28,7 @@ #include "llvm/ADT/SmallPtrSet.h" #include #include +#include #define DEBUG_TYPE "parallel-lower-opt" @@ -146,6 +147,9 @@ struct AlwaysInlinerInterface : public InlinerInterface { // TODO mlir::LLVM::LLVMFuncOp GetOrCreateMallocFunction(ModuleOp module) { + static std::mutex _mutex; + std::unique_lock lock(_mutex); + mlir::OpBuilder builder(module.getContext()); SymbolTableCollection symbolTable; if (auto fn = dyn_cast_or_null( @@ -162,6 +166,9 @@ mlir::LLVM::LLVMFuncOp GetOrCreateMallocFunction(ModuleOp module) { lnk); } mlir::LLVM::LLVMFuncOp GetOrCreateFreeFunction(ModuleOp module) { + static std::mutex _mutex; + std::unique_lock lock(_mutex); + mlir::OpBuilder builder(module.getContext()); SymbolTableCollection symbolTable; if (auto fn = dyn_cast_or_null(