Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/polygeist/Passes/ParallelLower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "llvm/ADT/SmallPtrSet.h"
#include <algorithm>
#include <mlir/Dialect/Arithmetic/IR/Arithmetic.h>
#include <mutex>

#define DEBUG_TYPE "parallel-lower-opt"

Expand Down Expand Up @@ -146,6 +147,9 @@ struct AlwaysInlinerInterface : public InlinerInterface {

// TODO
mlir::LLVM::LLVMFuncOp GetOrCreateMallocFunction(ModuleOp module) {
static std::mutex _mutex;
std::unique_lock<std::mutex> lock(_mutex);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

   std::unique_lock lock(_mutex); 

or

   std::unique_lock lock{_mutex}; 

in C++17


mlir::OpBuilder builder(module.getContext());
SymbolTableCollection symbolTable;
if (auto fn = dyn_cast_or_null<LLVM::LLVMFuncOp>(
Expand All @@ -162,6 +166,9 @@ mlir::LLVM::LLVMFuncOp GetOrCreateMallocFunction(ModuleOp module) {
lnk);
}
mlir::LLVM::LLVMFuncOp GetOrCreateFreeFunction(ModuleOp module) {
static std::mutex _mutex;
std::unique_lock<std::mutex> lock(_mutex);

mlir::OpBuilder builder(module.getContext());
SymbolTableCollection symbolTable;
if (auto fn = dyn_cast_or_null<LLVM::LLVMFuncOp>(
Expand Down