[flang-commits] [flang] [Flang][OpenMP] Correct ArrayElements in Reduction Clause (PR #196094)
Tom Eccles via flang-commits
flang-commits at lists.llvm.org
Tue Jun 30 11:55:24 PDT 2026
================
@@ -1587,6 +1415,188 @@ struct OpWithBodyGenInfo {
bool privatize = true;
};
+static mlir::Value getReductionOverrideValue(fir::FirOpBuilder &builder,
+ mlir::Location loc,
+ const Object *object,
+ mlir::BlockArgument arg) {
+ if (hlfir::isFortranEntityWithAttributes(arg))
+ return arg;
+
+ fir::FortranVariableFlagsAttr attributes;
+ llvm::SmallVector<mlir::Value> typeParams;
+ auto declareOp = hlfir::DeclareOp::create(
+ builder, loc, arg, "omp.reduction.element", nullptr, typeParams, nullptr,
+ nullptr, 0, attributes);
+ return declareOp.getBase();
+}
+
+static void
+addReductionObjectOverrides(fir::FirOpBuilder &builder, mlir::Location loc,
+ lower::ExprToValueMap &overrides,
+ const ObjectEntryBlockArgsEntry &entry,
+ llvm::ArrayRef<mlir::BlockArgument> blockArgs) {
+ if (entry.objects.empty())
+ return;
+
+ assert(entry.objects.size() == blockArgs.size() &&
+ "reduction object list must match block arguments");
+ for (auto pair : llvm::zip_equal(entry.objects, blockArgs)) {
----------------
tblah wrote:
nit: I think llvm::zip_equal includes the assert (at least according to the programmer's manual)
https://github.com/llvm/llvm-project/pull/196094
More information about the flang-commits
mailing list