[flang-commits] [flang] [flang][OpenMP] Do not emit a use-only item for a reduction symbol in a module file (PR #207492)

Sairudra More via flang-commits flang-commits at lists.llvm.org
Sun Jul 5 01:03:46 PDT 2026


================
@@ -890,6 +890,21 @@ void ModFileWriter::PutGeneric(const Symbol &symbol) {
 }
 
 void ModFileWriter::PutUse(const Symbol &symbol) {
+  // A user-defined operator declare reduction has an internal mangled
+  // symbol name ("op.<operator>.") that is not valid Fortran and cannot be
+  // emitted as a "use,only:" item: doing so produces a module file that fails
+  // to re-parse (both for a plain re-export and for an embedded module in a
+  // hermetic module file). Such a reduction is re-exported implicitly with its
+  // operator, which is emitted, and the reduction resolver recovers it from
+  // there (FindUserReductionSymbol / SearchOperatorReduction), so skip its use
+  // item. A reduction named by a plain identifier ("myred") has a valid name
+  // and is emitted normally; an intrinsic-operator or special-intrinsic
+  // reduction has no re-exported operator to recover through and is left to the
+  // normal path.
----------------
Saieiei wrote:

Could this comment clarify that the intrinsic/special cases are still a known limitation/follow-up? The “left to the normal path” wording sounds benign, but for facade re-exports, `op.+` / `op.max` can still be emitted as invalid `use, only:` items and fail when the module is read. Also, the `operator(+)` case with a user `interface operator(+)` seems recoverable like the `.remote.` case — is leaving that out intentional?

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


More information about the flang-commits mailing list