diff --git a/flang/lib/Lower/OpenMP/ReductionProcessor.cpp b/flang/lib/Lower/OpenMP/ReductionProcessor.cpp index 2477f635792a25..00fc70b519b5aa 100644 --- a/flang/lib/Lower/OpenMP/ReductionProcessor.cpp +++ b/flang/lib/Lower/OpenMP/ReductionProcessor.cpp @@ -81,10 +81,15 @@ bool ReductionProcessor::supportedIntrinsicProcReduction( return redType; } -std::string -ReductionProcessor::getReductionName(llvm::StringRef name, - const fir::KindMapping &kindMap, - mlir::Type ty, bool isByRef) { +std::string ReductionProcessor::getReductionName(llvm::StringRef name, + const fir::KindMapping &kindMap, + mlir::Type ty, bool isByRef) { + ty = fir::unwrapRefType(ty); + std::string byrefSuffix = isByRef ? "_byref" : ""; + std::string typeString = fir::getTypeAsString(ty, kindMap, ""); + return name.str() + byrefSuffix + typeString; +} + ty = fir::unwrapRefType(ty); // extra string to distinguish reduction functions for variables passed by @@ -93,7 +98,9 @@ ReductionProcessor::getReductionName(llvm::StringRef name, if (isByRef) byrefAddition = "_byref"; - return fir::getTypeAsString(ty, kindMap, (name + byrefAddition).str()); +std::string resultName = name.str() + byrefAddition; +return fir::getTypeAsString(ty, kindMap, resultName); + } std::string ReductionProcessor::getReductionName(