[Mlir-commits] [mlir] [mlir][OpenMP] don't add compiler-generated barrier in single threaded code (PR #174105)
Jack Styles
llvmlistbot at llvm.org
Mon Jan 5 01:31:12 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))
----------------
Stylie777 wrote:
Makes sense, thanks.
https://github.com/llvm/llvm-project/pull/174105
More information about the Mlir-commits
mailing list