[flang-commits] [flang] [Flang][OpenMP] Access full list of entry block syms and vars (NFC) (PR #113681)
Sergio Afonso via flang-commits
flang-commits at lists.llvm.org
Wed Oct 30 04:24:27 PDT 2024
https://github.com/skatrak updated https://github.com/llvm/llvm-project/pull/113681
>From 815910bccf1e3ccf81dbbaecd97fa6815fd0f25f Mon Sep 17 00:00:00 2001
From: Sergio Afonso <safonsof at amd.com>
Date: Fri, 25 Oct 2024 11:33:50 +0100
Subject: [PATCH] [Flang][OpenMP] Access full list of entry block syms and vars
(NFC)
This patch adds methods to `EntryBlockArgs` to access the full list of entry
block argument-related symbols and variables, in their standard order. This
helps centralizing this logic in as few places as possible to avoid future
inconsistencies.
---
flang/lib/Lower/OpenMP/OpenMP.cpp | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp
index 01a40d6e2204ef..876feca9b6f5be 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -76,6 +76,18 @@ struct EntryBlockArgs {
reduction.isValid() && taskReduction.isValid() &&
useDeviceAddr.isValid() && useDevicePtr.isValid();
}
+
+ auto getSyms() const {
+ return llvm::concat<const semantics::Symbol *const>(
+ inReduction.syms, map.syms, priv.syms, reduction.syms,
+ taskReduction.syms, useDeviceAddr.syms, useDevicePtr.syms);
+ }
+
+ auto getVars() const {
+ return llvm::concat<const mlir::Value>(
+ inReduction.vars, map.vars, priv.vars, reduction.vars,
+ taskReduction.vars, useDeviceAddr.vars, useDevicePtr.vars);
+ }
};
} // namespace
@@ -1506,8 +1518,7 @@ genParallelOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
genEntryBlock(converter, args, op->getRegion(0));
bindEntryBlockArgs(
converter, llvm::cast<mlir::omp::BlockArgOpenMPOpInterface>(op), args);
- return llvm::to_vector(llvm::concat<const semantics::Symbol *const>(
- args.priv.syms, args.reduction.syms));
+ return llvm::to_vector(args.getSyms());
};
assert((!enableDelayedPrivatization || dsp) &&
@@ -1581,11 +1592,11 @@ genSectionsOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
mlir::Operation *terminator =
lower::genOpenMPTerminator(builder, sectionsOp, loc);
- auto reductionCallback = [&](mlir::Operation *op) {
+ auto genRegionEntryCB = [&](mlir::Operation *op) {
genEntryBlock(converter, args, op->getRegion(0));
bindEntryBlockArgs(
converter, llvm::cast<mlir::omp::BlockArgOpenMPOpInterface>(op), args);
- return reductionSyms;
+ return llvm::to_vector(args.getSyms());
};
// Generate nested SECTION constructs.
@@ -1611,7 +1622,7 @@ genSectionsOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
OpWithBodyGenInfo(converter, symTable, semaCtx, loc, nestedEval,
llvm::omp::Directive::OMPD_section)
.setClauses(§ionQueue.begin()->clauses)
- .setGenRegionEntryCb(reductionCallback),
+ .setGenRegionEntryCb(genRegionEntryCB),
sectionQueue, sectionQueue.begin());
}
More information about the flang-commits
mailing list