[flang-commits] [flang] [llvm] [flang][MIF] Adding lowering for EVENT POST/WAIT statements (PR #210283)

Dan Bonachea via flang-commits flang-commits at lists.llvm.org
Wed Oct 7 13:47:06 PDT 2026


================
@@ -341,6 +341,29 @@ mlir::Value Fortran::lower::genInitialDataTarget(
                               /*slice=*/mlir::Value{});
 }
 
+static mlir::Value
+genCoarrayDefaultInitializerValue(Fortran::lower::AbstractConverter &converter,
+                                  mlir::Location loc, mlir::Type boxType) {
+  fir::FirOpBuilder &builder = converter.getFirOpBuilder();
+  auto baseBoxType = mlir::cast<fir::BaseBoxType>(boxType);
+  auto baseAddrType = baseBoxType.getBaseAddressType();
+  auto type = fir::unwrapRefType(baseAddrType);
+  auto nullAddr = builder.createNullConstant(loc, baseAddrType);
+  mlir::Value shape, slice;
+  if (auto seqTy = mlir::dyn_cast<fir::SequenceType>(type)) {
+    llvm::SmallVector<mlir::Value> extents;
+    for (int64_t extent : seqTy.getShape())
+      extents.push_back(
+          builder.createIntegerConstant(loc, builder.getIndexType(), extent));
+    shape = builder.createShape(
+        loc, fir::ArrayBoxValue{nullAddr, extents, /*lbounds=*/{}});
----------------
bonachea wrote:

Thanks for finding this!

I've confirmed/replicated this defect using the program above with Caffeine, which detects the problem in debug mode:
```
cgpu$ flang -fcoarray event_test9.F90 -L$PREFIX/lib -lcaffeine-smp-seq -lgasnet-smp-seq && a.out  
warning: Support for multi image Fortran features is still experimental and in development.
*** FATAL ERROR (proc 0): Assertion failure on image 1 at ././src/caffeine/events_s.F90:17: call_assert(offset >= 0)
*** FATAL ERROR (proc 2): Assertion failure on image 3 at ././src/caffeine/events_s.F90:17: call_assert(offset >= 0)
*** FATAL ERROR (proc 1): Assertion failure on image 2 at ././src/caffeine/events_s.F90:17: call_assert(offset >= 0)
*** NOTICE (proc 2): Before reporting bugs, run with GASNET_BACKTRACE=1 in the environment to generate a backtrace.
*** FATAL ERROR (proc 3): Assertion failure on image 4 at ././src/caffeine/events_s.F90:17: call_assert(offset >= 0)
*** NOTICE (proc 0): Before reporting bugs, run with GASNET_BACKTRACE=1 in the environment to generate a backtrace.
*** NOTICE (proc 1): Before reporting bugs, run with GASNET_BACKTRACE=1 in the environment to generate a backtrace.
*** NOTICE (proc 3): Before reporting bugs, run with GASNET_BACKTRACE=1 in the environment to generate a backtrace.
*** Caught a fatal signal (proc 2): SIGABRT(6)
*** Caught a fatal signal (proc 0): SIGABRT(6)
*** Caught a fatal signal (proc 1): SIGABRT(6)
*** Caught a fatal signal (proc 3): SIGABRT(6)
```

I believe fixing this (or at least detecting this case and issuing a TODO) is a blocker for merge

https://github.com/llvm/llvm-project/pull/210283


More information about the flang-commits mailing list