[flang-commits] [flang] [mlir] Fixing miscompilation with OMP synchronization at higher optimizations (PR #202258)
via flang-commits
flang-commits at lists.llvm.org
Thu Aug 13 20:59:39 PDT 2026
================
@@ -42,6 +43,21 @@ class FunctionAttrPass : public fir::impl::FunctionAttrBase<FunctionAttrPass> {
void runOnOperation() override;
};
+/// Return true if the function body contains any OpenMP synchronization or
+/// work-sharing constructs.
+static bool containsOpenMPSyncOrWorkshare(mlir::func::FuncOp func) {
+ bool found = false;
+ func.walk([&](mlir::Operation *op) {
+ if (mlir::isa<mlir::omp::SingleOp, mlir::omp::MasterOp,
+ mlir::omp::BarrierOp, mlir::omp::CriticalOp,
+ mlir::omp::OrderedOp, mlir::omp::ParallelOp>(op)) {
----------------
Ritanya-B-Bharadwaj wrote:
Right! Removed MasterOp.
You're right. Flang does put `noalias` on `x`, and since the barrier's hidden in `bar()`, x looks unmodified across the call. Your single-read version happens to stay put, but with a second read Global Value Numbering pass forwards the pre-`bar()` value across it. My pin only fires at a construct in the same function, so it misses this. Handling it means pinning args around every call under `-fopenmp `. Should I do it in this PR? or is it a known limitation?
https://github.com/llvm/llvm-project/pull/202258
More information about the flang-commits
mailing list