[flang-commits] [flang] [Flang][OpenMP] Fix crash and IR errors for user-defined reduction on allocatable variables (PR #186765)

via flang-commits flang-commits at lists.llvm.org
Thu Jul 2 00:53:28 PDT 2026


================
@@ -803,6 +804,185 @@ bool ReductionProcessor::processReductionArguments(
                          &redOperator.u)) {
         if (!ReductionProcessor::supportedIntrinsicProcReduction(
                 *reductionIntrinsic)) {
+          if (isByRef) {
+            // create a new declare_reduction for the boxed type, reusing
+            // the existing init and combiner
+            semantics::Symbol *sym = reductionIntrinsic->v.sym();
+            llvm::StringRef baseName = {sym->name().begin(),
+                                        sym->name().size()};
+            mlir::ModuleOp module = builder.getModule();
+            auto existingDecl = module.lookupSymbol<OpType>(baseName);
----------------
MattPD wrote:

After a rebase onto current `main`, this bare-name lookup will likely stop finding the base declaration and fall into the TODO just below. Current `main` names user-defined reduction ops with a scope-qualified name (`getScopedUserReductionName` / `mangleName`), and this branch is a few thousand commits behind. Flagging it for the rebase.

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


More information about the flang-commits mailing list