================
@@ -573,10 +573,18 @@ OpType ReductionProcessor::createDeclareReduction(
 
   mlir::OpBuilder modBuilder(module.getBodyRegion());
   mlir::Type valTy = fir::unwrapRefType(type);
+  // For by-ref reductions, we want to keep track of the
+  // boxed/referenced/allocated type. For example, a for `real, allocatable`
+  // variable, `real` should be stored.
+  mlir::TypeAttr boxedTy{};
+
   if (!isByRef)
     type = valTy;
 
-  decl = OpType::create(modBuilder, loc, reductionOpName, type);
+  if (isByRef)
+    boxedTy = mlir::TypeAttr::get(fir::unwrapPassByRefType(valTy));
----------------
tblah wrote:

```suggestion
  if (isByRef)
    boxedTy = mlir::TypeAttr::get(fir::unwrapPassByRefType(valTy));
  else
    type = valTy;
```

https://github.com/llvm/llvm-project/pull/165714
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to