================
@@ -390,15 +559,35 @@ void ReductionProcessor::addReductionDecl(
 
   // initial pass to collect all recuction vars so we can figure out if this
   // should happen byref
+  fir::FirOpBuilder &builder = converter.getFirOpBuilder();
   for (const Fortran::parser::OmpObject &ompObject : objectList.v) {
     if (const auto *name{
             Fortran::parser::Unwrap<Fortran::parser::Name>(ompObject)}) {
       if (const Fortran::semantics::Symbol * symbol{name->symbol}) {
         if (reductionSymbols)
           reductionSymbols->push_back(symbol);
         mlir::Value symVal = converter.getSymbolAddress(*symbol);
-        if (auto declOp = symVal.getDefiningOp<hlfir::DeclareOp>())
+        auto redType = mlir::cast<fir::ReferenceType>(symVal.getType());
----------------
tblah wrote:

The existing upstream code already does this, I was mostly moving code around 
here. See line 434 in the old version of the code.

This even predates the by-ref reduction changes. See 
https://github.com/llvm/llvm-project/blob/f18d78b477c76bc09dc580cdaedd55e121f5ebf5/flang/lib/Lower/OpenMP/ReductionProcessor.cpp#L347

For example, if you look at the llvm code we generate by-val reductions (which 
should be identical after my changes), it loaded the reduction variables 
unconditionally, so this must be some kind of pointer.

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

Reply via email to