[Mlir-commits] [mlir] [mlir][OpenMP] don't add compiler-generated barrier in single threaded code (PR #174105)
Tom Eccles
llvmlistbot at llvm.org
Mon Jan 5 01:27:25 PST 2026
================
@@ -1678,6 +1678,25 @@ allocatePrivateVars(llvm::IRBuilderBase &builder,
return afterAllocas;
}
+// This can't always be determined statically, but when we can, it is good to
+// avoid generating compiler-added barriers which will deadlock the program.
+static bool opIsInSingleThread(mlir::Operation *op) {
+ while (mlir::Operation *parent = op->getParentOp()) {
+ if (mlir::isa<omp::SingleOp, omp::CriticalOp>(parent))
+ return true;
+
+ // e.g.
+ // omp.single {
+ // omp.parallel {
+ // op
+ // }
+ // }
+ if (mlir::isa<omp::ParallelOp>(parent))
----------------
tblah wrote:
No. Because otherwise the example in the comment above would return true.
https://github.com/llvm/llvm-project/pull/174105
More information about the Mlir-commits
mailing list