[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
Tue Mar 17 05:02:42 PDT 2026
================
@@ -803,6 +804,185 @@ bool ReductionProcessor::processReductionArguments(
&redOperator.u)) {
if (!ReductionProcessor::supportedIntrinsicProcReduction(
*reductionIntrinsic)) {
+ if (isByRef) {
+ // User-defined reduction on allocatable/pointer variable-
+ // we need a new declare_reduction for the boxed type, reusing
+ // the init value and combiner from the existing one.
+ semantics::Symbol *sym = reductionIntrinsic->v.sym();
+ std::string baseName = sym->name().ToString();
+ mlir::ModuleOp module = builder.getModule();
+ auto existingDecl = module.lookupSymbol<OpType>(baseName);
+ if (!existingDecl) {
+ TODO(currentLocation,
+ "User-defined reductions on allocatable or pointer "
+ "variables: cannot find base reduction declaration");
+ }
+
+ std::string byrefName = getReductionName(
----------------
Ritanya-B-Bharadwaj wrote:
getReductionName returns std::string since it builds the name dynamically via fir::getTypeAsString.
https://github.com/llvm/llvm-project/pull/186765
More information about the flang-commits
mailing list