[flang-commits] [flang] [flang][OpenMP] Fix wrong results for FORALL in a workshare construct (PR #211371)
Carlos Seo via flang-commits
flang-commits at lists.llvm.org
Wed Aug 5 06:37:18 PDT 2026
================
@@ -328,9 +359,19 @@ static void collectThreadLocalWrites(Operation *op,
// Reads are matched by their underlying thread-local allocation, mirroring
// collectThreadLocalWrites, so that a load through a fir.declare/fir.convert
// still keeps the corresponding write live for broadcasting.
-static void collectThreadLocalReads(Region &scope,
- llvm::SmallDenseSet<Value> &reads) {
+//
+// An opaque call may read any thread-local location inside its callee, and a
+// memory-effecting operation may report a read of unspecified memory (a read
+// effect with no attached value). Neither read can be attributed to a specific
+// location, so reads.unknown is set to force every thread-local write to be
+// broadcasted. Other interface-less operations (e.g. omp.barrier, fir.declare)
+// have known, inspectable behaviour and are safe to ignore here.
+static void collectThreadLocalReads(Region &scope, ThreadLocalReads &reads) {
scope.walk([&](Operation *op) {
+ if (isa<mlir::CallOpInterface>(op)) {
+ reads.unknown = true;
+ return;
+ }
auto memEffects = dyn_cast<MemoryEffectOpInterface>(op);
if (!memEffects)
return;
----------------
ceseo wrote:
Will do.
You may take it if you wish. I still have a bunch of patches to review and submit in the following weeks. If you do start working on this, please check the Fujitsu testsuite board (https://github.com/orgs/llvm/projects/20/views/1). I think it's likely that there are bugs reported there for other dialects that may be related to this.
https://github.com/llvm/llvm-project/pull/211371
More information about the flang-commits
mailing list