[flang-commits] [clang] [flang] [llvm] [mlir] [OpenMP][flang] Add initial support for by-ref reductions on the GPU (PR #165714)

Tom Eccles via flang-commits flang-commits at lists.llvm.org
Wed Nov 5 10:09:53 PST 2025


================
@@ -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


More information about the flang-commits mailing list