================ @@ -92,10 +93,42 @@ std::string ReductionProcessor::getReductionName(llvm::StringRef name, if (isByRef) byrefAddition = "_byref"; - return (llvm::Twine(name) + - (ty.isIntOrIndex() ? llvm::Twine("_i_") : llvm::Twine("_f_")) + - llvm::Twine(ty.getIntOrFloatBitWidth()) + byrefAddition) - .str(); + if (fir::isa_trivial(ty)) + return (llvm::Twine(name) + + (ty.isIntOrIndex() ? llvm::Twine("_i_") : llvm::Twine("_f_")) + + llvm::Twine(ty.getIntOrFloatBitWidth()) + byrefAddition) + .str(); + + // creates a name like reduction_i_64_box_ux4x3 + if (auto boxTy = mlir::dyn_cast_or_null<fir::BaseBoxType>(ty)) { + // TODO: support for allocatable boxes: + // !fir.box<!fir.heap<!fir.array<...>>> + fir::SequenceType seqTy = fir::unwrapRefType(boxTy.getEleTy()) + .dyn_cast_or_null<fir::SequenceType>(); + if (!seqTy) + return {}; + + std::string prefix = getReductionName( + name, fir::unwrapSeqOrBoxedSeqType(ty), /*isByRef=*/false); + if (prefix.empty()) + return {}; + std::stringstream tyStr; + tyStr << prefix << "_box_"; + bool first = true; + for (std::int64_t extent : seqTy.getShape()) { + if (first) + first = false; + else + tyStr << "x"; + if (extent == seqTy.getUnknownExtent()) + tyStr << 'u'; // I'm not sure that '?' is safe in symbol names + else + tyStr << extent; + } + return (tyStr.str() + byrefAddition).str(); + } + + return {}; ---------------- kiranchandramohan wrote:
OK, that is fine. https://github.com/llvm/llvm-project/pull/84958 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits