[flang-commits] [flang] [Flang][OpenMP][NFC] Remove Fortran Evaluate Depedancy from Support (PR #198742)
Jack Styles via flang-commits
flang-commits at lists.llvm.org
Wed May 20 02:59:38 PDT 2026
https://github.com/Stylie777 created https://github.com/llvm/llvm-project/pull/198742
Following #197442, FortranEvaluate was implicitly included in OpenMP-utils.h which should be avoided to ensure front-end data structures in the Optimizers can stop and restart pure MLIR source without any side-data structures.
To ensure this is done, EntryBlockArgs has been stripped back to only track vars, objects are now tracked within ObjectEntryBlockArgs in Lowering as this is a more appropriate place for this information, and the existing symbol tracking in EntryBlockArgsEntry was only used here. This ensures FortranEvaluate is not needed within the Optimizers, and objects can still be maintained when lowering. This enables better referencing in Reduction Clauses, where previously context was being lost for expressions such as ArrayElements.
See more: #197442
Assisted-by: Codex
>From 86b04121f21a5057ba1e6438d42d74d673fa91ad Mon Sep 17 00:00:00 2001
From: Jack Styles <jack.styles at arm.com>
Date: Wed, 20 May 2026 09:57:58 +0100
Subject: [PATCH] [Flang][OpenMP][NFC] Remove Fortran Evaluate Depedancy from
Support
Following #197442, FortranEvaluate was implicitly included in
OpenMP-utils.h which should be avoided to ensure front-end data
structures in the Optimizers can stop and restart pure MLIR source
without any side-data structures.
To ensure this is done, EntryBlockArgs has been stripped back to only
track vars, objects are now tracked within ObjectEntryBlockArgs in
Lowering as this is a more appropriate place for this information,
and the existing symbol tracking in EntryBlockArgsEntry was only
used here. This ensures FortranEvaluate is not needed within the
Optimizers, and objects can still be maintained when lowering. This
enables better referencing in Reduction Clauses, where previously
context was being lost for expressions such as ArrayElements.
See more: #197442
Assisted-by: Codex
---
flang/include/flang/Support/OpenMP-utils.h | 74 ++-----
flang/lib/Lower/OpenMP/OpenMP.cpp | 185 +++++++++++++-----
flang/lib/Optimizer/OpenMP/CMakeLists.txt | 1 -
.../OpenMP/DoConcurrentConversion.cpp | 8 +-
.../OpenMP/GenericLoopConversion.cpp | 8 +-
flang/lib/Support/OpenMP-utils.cpp | 27 ++-
6 files changed, 163 insertions(+), 140 deletions(-)
diff --git a/flang/include/flang/Support/OpenMP-utils.h b/flang/include/flang/Support/OpenMP-utils.h
index cb3d65441138f..3ebe22ac648c0 100644
--- a/flang/include/flang/Support/OpenMP-utils.h
+++ b/flang/include/flang/Support/OpenMP-utils.h
@@ -9,81 +9,29 @@
#ifndef FORTRAN_SUPPORT_OPENMP_UTILS_H_
#define FORTRAN_SUPPORT_OPENMP_UTILS_H_
-#include "flang/Lower/OpenMP/Clauses.h"
-#include "flang/Semantics/symbol.h"
-
#include "mlir/IR/Builders.h"
#include "mlir/IR/Value.h"
#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/SmallVector.h"
namespace Fortran::common::openmp {
-/// Structure holding the information needed to create and bind entry block
-/// arguments associated to a single clause.
-struct EntryBlockArgsEntry {
- llvm::SmallVector<Fortran::lower::omp::Object> objects;
- llvm::ArrayRef<mlir::Value> vars;
-
- bool isValid() const {
- // This check allows specifying a smaller number of objects than values
- // because in some case cases a single symbol generates multiple block
- // arguments.
- return objects.size() <= vars.size();
- }
-
- llvm::SmallVector<const Fortran::semantics::Symbol *> getSyms() const {
- llvm::SmallVector<const Fortran::semantics::Symbol *> syms;
- syms.reserve(objects.size());
- llvm::transform(objects, std::back_inserter(syms),
- [](const Fortran::lower::omp::Object &object) { return object.sym(); });
- return syms;
- }
-};
-
/// Structure holding the information needed to create and bind entry block
/// arguments associated to all clauses that can define them.
struct EntryBlockArgs {
- EntryBlockArgsEntry hasDeviceAddr;
+ llvm::ArrayRef<mlir::Value> hasDeviceAddrVars;
llvm::ArrayRef<mlir::Value> hostEvalVars;
- EntryBlockArgsEntry inReduction;
- EntryBlockArgsEntry map;
- EntryBlockArgsEntry priv;
- EntryBlockArgsEntry reduction;
- EntryBlockArgsEntry taskReduction;
- EntryBlockArgsEntry useDeviceAddr;
- EntryBlockArgsEntry useDevicePtr;
-
- bool isValid() const {
- return hasDeviceAddr.isValid() && inReduction.isValid() && map.isValid() &&
- priv.isValid() && reduction.isValid() && taskReduction.isValid() &&
- useDeviceAddr.isValid() && useDevicePtr.isValid();
- }
-
- llvm::SmallVector<const semantics::Symbol *> getSyms() const {
- llvm::SmallVector<const semantics::Symbol *> syms;
- auto appendSyms = [&syms](const EntryBlockArgsEntry &entry) {
- syms.reserve(syms.size() + entry.objects.size());
- llvm::transform(entry.objects, std::back_inserter(syms),
- [](const Fortran::lower::omp::Object &object) {
- return object.sym();
- });
- };
- appendSyms(hasDeviceAddr);
- appendSyms(inReduction);
- appendSyms(map);
- appendSyms(priv);
- appendSyms(reduction);
- appendSyms(taskReduction);
- appendSyms(useDeviceAddr);
- appendSyms(useDevicePtr);
- return syms;
- }
+ llvm::ArrayRef<mlir::Value> inReductionVars;
+ llvm::ArrayRef<mlir::Value> mapVars;
+ llvm::ArrayRef<mlir::Value> privVars;
+ llvm::ArrayRef<mlir::Value> reductionVars;
+ llvm::ArrayRef<mlir::Value> taskReductionVars;
+ llvm::ArrayRef<mlir::Value> useDeviceAddrVars;
+ llvm::ArrayRef<mlir::Value> useDevicePtrVars;
auto getVars() const {
- return llvm::concat<const mlir::Value>(hasDeviceAddr.vars, hostEvalVars,
- inReduction.vars, map.vars, priv.vars, reduction.vars,
- taskReduction.vars, useDeviceAddr.vars, useDevicePtr.vars);
+ return llvm::concat<const mlir::Value>(hasDeviceAddrVars, hostEvalVars,
+ inReductionVars, mapVars, privVars, reductionVars,
+ taskReductionVars, useDeviceAddrVars, useDevicePtrVars);
}
};
diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp
index 2b49d57f3d86f..4d69528f63ff4 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -251,6 +251,80 @@ class SectionsConstructStackFrame
const parser::OpenMPSectionsConstruct §ionsConstruct;
};
+/// Structure holding the information needed to create and bind entry block
+/// arguments associated to a single clause during OpenMP lowering.
+struct ObjectEntryBlockArgsEntry {
+ llvm::SmallVector<Object> objects;
+ llvm::ArrayRef<mlir::Value> vars;
+
+ bool isValid() const { return objects.size() <= vars.size(); }
+
+ llvm::SmallVector<const semantics::Symbol *> getSyms() const {
+ llvm::SmallVector<const semantics::Symbol *> syms;
+ syms.reserve(objects.size());
+ llvm::transform(objects, std::back_inserter(syms),
+ [](const Object &object) { return object.sym(); });
+ return syms;
+ }
+};
+
+struct ObjectEntryBlockArgs {
+ ObjectEntryBlockArgsEntry hasDeviceAddr;
+ llvm::ArrayRef<mlir::Value> hostEvalVars;
+ ObjectEntryBlockArgsEntry inReduction;
+ ObjectEntryBlockArgsEntry map;
+ ObjectEntryBlockArgsEntry priv;
+ ObjectEntryBlockArgsEntry reduction;
+ ObjectEntryBlockArgsEntry taskReduction;
+ ObjectEntryBlockArgsEntry useDeviceAddr;
+ ObjectEntryBlockArgsEntry useDevicePtr;
+
+ bool isValid() const {
+ return hasDeviceAddr.isValid() && inReduction.isValid() && map.isValid() &&
+ priv.isValid() && reduction.isValid() && taskReduction.isValid() &&
+ useDeviceAddr.isValid() && useDevicePtr.isValid();
+ }
+
+ llvm::SmallVector<const semantics::Symbol *> getSyms() const {
+ llvm::SmallVector<const semantics::Symbol *> syms;
+ auto appendSyms = [&syms](const ObjectEntryBlockArgsEntry &entry) {
+ syms.reserve(syms.size() + entry.objects.size());
+ llvm::transform(entry.objects, std::back_inserter(syms),
+ [](const Object &object) { return object.sym(); });
+ };
+ appendSyms(hasDeviceAddr);
+ appendSyms(inReduction);
+ appendSyms(map);
+ appendSyms(priv);
+ appendSyms(reduction);
+ appendSyms(taskReduction);
+ appendSyms(useDeviceAddr);
+ appendSyms(useDevicePtr);
+ return syms;
+ }
+
+ auto getVars() const {
+ return llvm::concat<const mlir::Value>(
+ hasDeviceAddr.vars, hostEvalVars, inReduction.vars, map.vars, priv.vars,
+ reduction.vars, taskReduction.vars, useDeviceAddr.vars,
+ useDevicePtr.vars);
+ }
+
+ Fortran::common::openmp::EntryBlockArgs asEntryBlockArgs() const {
+ Fortran::common::openmp::EntryBlockArgs args;
+ args.hasDeviceAddrVars = hasDeviceAddr.vars;
+ args.hostEvalVars = hostEvalVars;
+ args.inReductionVars = inReduction.vars;
+ args.mapVars = map.vars;
+ args.privVars = priv.vars;
+ args.reductionVars = reduction.vars;
+ args.taskReductionVars = taskReduction.vars;
+ args.useDeviceAddrVars = useDeviceAddr.vars;
+ args.useDevicePtrVars = useDevicePtr.vars;
+ return args;
+ }
+};
+
static const parser::OpenMPSectionsConstruct *
getSectionsConstructStackTop(lower::AbstractConverter &converter) {
SectionsConstructStackFrame *frame =
@@ -272,7 +346,7 @@ getSectionsConstructStackTop(lower::AbstractConverter &converter) {
/// operation.
static void bindEntryBlockArgs(lower::AbstractConverter &converter,
mlir::omp::BlockArgOpenMPOpInterface op,
- const EntryBlockArgs &args) {
+ const ObjectEntryBlockArgs &args) {
assert(op != nullptr && "invalid block argument-defining operation");
assert(args.isValid() && "invalid args");
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
@@ -881,12 +955,12 @@ getDeclareTargetFunctionDevice(
/// \param [in] args - symbols of induction variables.
/// \param [in] wrapperArgs - list of parent loop wrappers and their associated
/// entry block arguments.
-static void genLoopVars(
- mlir::Operation *op, lower::AbstractConverter &converter,
- mlir::Location &loc, llvm::ArrayRef<const semantics::Symbol *> args,
- llvm::ArrayRef<
- std::pair<mlir::omp::BlockArgOpenMPOpInterface, const EntryBlockArgs &>>
- wrapperArgs = {}) {
+static void
+genLoopVars(mlir::Operation *op, lower::AbstractConverter &converter,
+ mlir::Location &loc, llvm::ArrayRef<const semantics::Symbol *> args,
+ llvm::ArrayRef<std::pair<mlir::omp::BlockArgOpenMPOpInterface,
+ const ObjectEntryBlockArgs &>>
+ wrapperArgs = {}) {
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
auto ®ion = op->getRegion(0);
@@ -1135,7 +1209,7 @@ struct OpWithBodyGenInfo {
return *this;
}
- OpWithBodyGenInfo &setEntryBlockArgs(const EntryBlockArgs *value) {
+ OpWithBodyGenInfo &setEntryBlockArgs(const ObjectEntryBlockArgs *value) {
blockArgs = value;
return *this;
}
@@ -1174,7 +1248,7 @@ struct OpWithBodyGenInfo {
/// [in] if provided, it is used to create the op's region entry block. It is
/// overriden when a \see genRegionEntryCB is provided. This is only valid for
/// operations implementing the \see mlir::omp::BlockArgOpenMPOpInterface.
- const EntryBlockArgs *blockArgs = nullptr;
+ const ObjectEntryBlockArgs *blockArgs = nullptr;
/// [in] if provided, it overrides the default op's region entry block
/// creation.
GenOMPRegionEntryCBFn genRegionEntryCB = nullptr;
@@ -1218,7 +1292,8 @@ static void createBodyOfOp(mlir::Operation &op, const OpWithBodyGenInfo &info,
return info.genRegionEntryCB(&op);
if (info.blockArgs) {
- genEntryBlock(firOpBuilder, *info.blockArgs, op.getRegion(0));
+ genEntryBlock(firOpBuilder, info.blockArgs->asEntryBlockArgs(),
+ op.getRegion(0));
bindEntryBlockArgs(info.converter,
llvm::cast<mlir::omp::BlockArgOpenMPOpInterface>(op),
*info.blockArgs);
@@ -1360,12 +1435,12 @@ static void createBodyOfOp(mlir::Operation &op, const OpWithBodyGenInfo &info,
static void genBodyOfTargetDataOp(
lower::AbstractConverter &converter, lower::SymMap &symTable,
semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
- mlir::omp::TargetDataOp &dataOp, const EntryBlockArgs &args,
+ mlir::omp::TargetDataOp &dataOp, const ObjectEntryBlockArgs &args,
const mlir::Location ¤tLocation, const ConstructQueue &queue,
ConstructQueue::const_iterator item) {
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
- genEntryBlock(firOpBuilder, args, dataOp.getRegion());
+ genEntryBlock(firOpBuilder, args.asEntryBlockArgs(), dataOp.getRegion());
bindEntryBlockArgs(converter, dataOp, args);
// Insert dummy instruction to remember the insertion position. The
@@ -1435,14 +1510,14 @@ static void genIntermediateCommonBlockAccessors(
static void genBodyOfTargetOp(
lower::AbstractConverter &converter, lower::SymMap &symTable,
semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
- mlir::omp::TargetOp &targetOp, const EntryBlockArgs &args,
+ mlir::omp::TargetOp &targetOp, const ObjectEntryBlockArgs &args,
const mlir::Location ¤tLocation, const ConstructQueue &queue,
ConstructQueue::const_iterator item, DataSharingProcessor &dsp) {
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
auto argIface = llvm::cast<mlir::omp::BlockArgOpenMPOpInterface>(*targetOp);
mlir::Region ®ion = targetOp.getRegion();
- genEntryBlock(firOpBuilder, args, region);
+ genEntryBlock(firOpBuilder, args.asEntryBlockArgs(), region);
bindEntryBlockArgs(converter, targetOp, args);
if (HostEvalInfo *hostEvalInfo = getHostEvalInfoStackTop(converter))
hostEvalInfo->bindOperands(argIface.getHostEvalBlockArgs());
@@ -1508,7 +1583,7 @@ static OpTy genOpWithBody(const OpWithBodyGenInfo &info,
template <typename OpTy, typename ClauseOpsTy>
static OpTy genWrapperOp(lower::AbstractConverter &converter,
mlir::Location loc, const ClauseOpsTy &clauseOps,
- const EntryBlockArgs &args) {
+ const ObjectEntryBlockArgs &args) {
static_assert(
OpTy::template hasTrait<mlir::omp::LoopWrapperInterface::Trait>(),
"expected a loop wrapper");
@@ -1518,7 +1593,7 @@ static OpTy genWrapperOp(lower::AbstractConverter &converter,
auto op = OpTy::create(firOpBuilder, loc, clauseOps);
// Create entry block with arguments.
- genEntryBlock(firOpBuilder, args, op.getRegion());
+ genEntryBlock(firOpBuilder, args.asEntryBlockArgs(), op.getRegion());
return op;
}
@@ -2085,16 +2160,17 @@ genFlushOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
operandRange);
}
-static mlir::omp::LoopNestOp genLoopNestOp(
- lower::AbstractConverter &converter, lower::SymMap &symTable,
- semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
- mlir::Location loc, const ConstructQueue &queue,
- ConstructQueue::const_iterator item, mlir::omp::LoopNestOperands &clauseOps,
- llvm::ArrayRef<const semantics::Symbol *> iv,
- llvm::ArrayRef<
- std::pair<mlir::omp::BlockArgOpenMPOpInterface, const EntryBlockArgs &>>
- wrapperArgs,
- llvm::omp::Directive directive, DataSharingProcessor &dsp) {
+static mlir::omp::LoopNestOp
+genLoopNestOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval, mlir::Location loc,
+ const ConstructQueue &queue, ConstructQueue::const_iterator item,
+ mlir::omp::LoopNestOperands &clauseOps,
+ llvm::ArrayRef<const semantics::Symbol *> iv,
+ llvm::ArrayRef<std::pair<mlir::omp::BlockArgOpenMPOpInterface,
+ const ObjectEntryBlockArgs &>>
+ wrapperArgs,
+ llvm::omp::Directive directive, DataSharingProcessor &dsp) {
auto ivCallback = [&](mlir::Operation *op) {
genLoopVars(op, converter, loc, iv, wrapperArgs);
return llvm::SmallVector<const semantics::Symbol *>(iv);
@@ -2132,7 +2208,7 @@ genLoopOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
genLoopNestClauses(converter, semaCtx, eval, item->clauses, loc,
loopNestClauseOps, iv);
- EntryBlockArgs loopArgs;
+ ObjectEntryBlockArgs loopArgs;
loopArgs.priv.objects = makeObjects(dsp.getDelayedPrivSymbols());
loopArgs.priv.vars = loopClauseOps.privateVars;
loopArgs.reduction.objects = loopReductionObjects;
@@ -2539,7 +2615,7 @@ genParallelOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
lower::pft::Evaluation &eval, mlir::Location loc,
const ConstructQueue &queue, ConstructQueue::const_iterator item,
mlir::omp::ParallelOperands &clauseOps,
- const EntryBlockArgs &args, DataSharingProcessor *dsp,
+ const ObjectEntryBlockArgs &args, DataSharingProcessor *dsp,
bool isComposite = false) {
assert((!enableDelayedPrivatization || dsp) &&
"expected valid DataSharingProcessor");
@@ -2618,12 +2694,12 @@ genSectionsOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
auto sectionsOp = mlir::omp::SectionsOp::create(builder, loc, clauseOps);
// Create entry block with reduction variables as arguments.
- EntryBlockArgs args;
+ ObjectEntryBlockArgs args;
// TODO: Add private syms and vars.
args.reduction.objects = reductionObjects;
args.reduction.vars = clauseOps.reductionVars;
- genEntryBlock(builder, args, sectionsOp.getRegion());
+ genEntryBlock(builder, args.asEntryBlockArgs(), sectionsOp.getRegion());
mlir::Operation *terminator =
lower::genOpenMPTerminator(builder, sectionsOp, loc);
@@ -2715,7 +2791,7 @@ genScopeOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
dsp->processStep1(&clauseOps);
}
- EntryBlockArgs args;
+ ObjectEntryBlockArgs args;
if (dsp)
args.priv.objects = makeObjects(dsp->getDelayedPrivSymbols());
args.priv.vars = clauseOps.privateVars;
@@ -3040,7 +3116,7 @@ genTargetOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
extractMappedBaseValues(clauseOps.hasDeviceAddrVars, hasDeviceAddrBaseValues);
extractMappedBaseValues(clauseOps.mapVars, mapBaseValues);
- EntryBlockArgs args;
+ ObjectEntryBlockArgs args;
args.hasDeviceAddr.objects = hasDeviceAddrObjects;
args.hasDeviceAddr.vars = hasDeviceAddrBaseValues;
args.hostEvalVars = clauseOps.hostEvalVars;
@@ -3077,7 +3153,7 @@ static mlir::omp::TargetDataOp genTargetDataOp(
extractMappedBaseValues(clauseOps.useDeviceAddrVars, useDeviceAddrBaseValues);
extractMappedBaseValues(clauseOps.useDevicePtrVars, useDevicePtrBaseValues);
- EntryBlockArgs args;
+ ObjectEntryBlockArgs args;
args.useDeviceAddr.objects = useDeviceAddrObjects;
args.useDeviceAddr.vars = useDeviceAddrBaseValues;
args.useDevicePtr.objects = useDevicePtrObjects;
@@ -3138,7 +3214,7 @@ genTaskOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
/*useDelayedPrivatization=*/true, symTable);
dsp.processStep1(&clauseOps);
- EntryBlockArgs taskArgs;
+ ObjectEntryBlockArgs taskArgs;
taskArgs.priv.objects = makeObjects(dsp.getDelayedPrivSymbols());
taskArgs.priv.vars = clauseOps.privateVars;
taskArgs.inReduction.objects = inReductionObjects;
@@ -3164,7 +3240,7 @@ genTaskgroupOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
genTaskgroupClauses(converter, semaCtx, item->clauses, loc, clauseOps,
taskReductionObjects);
- EntryBlockArgs taskgroupArgs;
+ ObjectEntryBlockArgs taskgroupArgs;
taskgroupArgs.taskReduction.objects = taskReductionObjects;
taskgroupArgs.taskReduction.vars = clauseOps.taskReductionVars;
@@ -3225,7 +3301,7 @@ genTeamsOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
genTeamsClauses(converter, semaCtx, stmtCtx, item->clauses, loc, clauseOps,
reductionObjects);
- EntryBlockArgs args;
+ ObjectEntryBlockArgs args;
// TODO: Add private syms and vars.
args.reduction.objects = reductionObjects;
args.reduction.vars = clauseOps.reductionVars;
@@ -3272,7 +3348,7 @@ static mlir::omp::DistributeOp genStandaloneDistribute(
genLoopNestClauses(converter, semaCtx, eval, item->clauses, loc,
loopNestClauseOps, iv);
- EntryBlockArgs distributeArgs;
+ ObjectEntryBlockArgs distributeArgs;
distributeArgs.priv.objects = makeObjects(dsp.getDelayedPrivSymbols());
distributeArgs.priv.vars = distributeClauseOps.privateVars;
auto distributeOp = genWrapperOp<mlir::omp::DistributeOp>(
@@ -3304,7 +3380,7 @@ static mlir::omp::WsloopOp genStandaloneDo(
genLoopNestClauses(converter, semaCtx, eval, item->clauses, loc,
loopNestClauseOps, iv);
- EntryBlockArgs wsloopArgs;
+ ObjectEntryBlockArgs wsloopArgs;
wsloopArgs.priv.objects = makeObjects(dsp.getDelayedPrivSymbols());
wsloopArgs.priv.vars = wsloopClauseOps.privateVars;
wsloopArgs.reduction.objects = wsloopReductionObjects;
@@ -3337,7 +3413,7 @@ static mlir::omp::ParallelOp genStandaloneParallel(
dsp->processStep1(¶llelClauseOps);
}
- EntryBlockArgs parallelArgs;
+ ObjectEntryBlockArgs parallelArgs;
if (dsp)
parallelArgs.priv.objects = makeObjects(dsp->getDelayedPrivSymbols());
parallelArgs.priv.vars = parallelClauseOps.privateVars;
@@ -3371,7 +3447,7 @@ genStandaloneSimd(lower::AbstractConverter &converter, lower::SymMap &symTable,
genSimdImplicitLinear(converter, semaCtx, simdClauseOps, loopNestClauseOps,
iv);
- EntryBlockArgs simdArgs;
+ ObjectEntryBlockArgs simdArgs;
simdArgs.priv.objects = makeObjects(dsp.getDelayedPrivSymbols());
simdArgs.priv.vars = simdClauseOps.privateVars;
simdArgs.reduction.objects = simdReductionObjects;
@@ -3405,7 +3481,7 @@ static mlir::omp::TaskloopContextOp genStandaloneTaskloop(
genLoopNestClauses(converter, semaCtx, eval, item->clauses, loc,
loopNestClauseOps, iv);
- EntryBlockArgs taskloopArgs;
+ ObjectEntryBlockArgs taskloopArgs;
taskloopArgs.priv.objects = makeObjects(dsp.getDelayedPrivSymbols());
taskloopArgs.priv.vars = taskloopClauseOps.privateVars;
taskloopArgs.reduction.objects = reductionObjects;
@@ -3417,12 +3493,13 @@ static mlir::omp::TaskloopContextOp genStandaloneTaskloop(
auto taskLoopContextOp = mlir::omp::TaskloopContextOp::create(
firOpBuilder, loc, taskloopClauseOps);
// Create entry block with arguments.
- genEntryBlock(firOpBuilder, taskloopArgs, taskLoopContextOp.getRegion());
+ genEntryBlock(firOpBuilder, taskloopArgs.asEntryBlockArgs(),
+ taskLoopContextOp.getRegion());
mlir::OpBuilder::InsertionGuard guard(firOpBuilder);
firOpBuilder.setInsertionPointToStart(&taskLoopContextOp.getRegion().front());
mlir::omp::TaskloopWrapperOperands wrapperClauseOps;
- EntryBlockArgs wrapperEntryBlockArgs;
+ ObjectEntryBlockArgs wrapperEntryBlockArgs;
auto taskLoopWrapperOp = genWrapperOp<mlir::omp::TaskloopWrapperOp>(
converter, loc, wrapperClauseOps, wrapperEntryBlockArgs);
@@ -3460,7 +3537,7 @@ static mlir::omp::DistributeOp genCompositeDistributeParallelDo(
/*useDelayedPrivatization=*/true, symTable);
dsp.processStep1(¶llelClauseOps);
- EntryBlockArgs parallelArgs;
+ ObjectEntryBlockArgs parallelArgs;
parallelArgs.priv.objects = makeObjects(dsp.getDelayedPrivSymbols());
parallelArgs.priv.vars = parallelClauseOps.privateVars;
parallelArgs.reduction.objects = parallelReductionObjects;
@@ -3484,13 +3561,13 @@ static mlir::omp::DistributeOp genCompositeDistributeParallelDo(
loopNestClauseOps, iv);
// Operation creation.
- EntryBlockArgs distributeArgs;
+ ObjectEntryBlockArgs distributeArgs;
// TODO: Add private syms and vars.
auto distributeOp = genWrapperOp<mlir::omp::DistributeOp>(
converter, loc, distributeClauseOps, distributeArgs);
distributeOp.setComposite(/*val=*/true);
- EntryBlockArgs wsloopArgs;
+ ObjectEntryBlockArgs wsloopArgs;
// TODO: Add private syms and vars.
wsloopArgs.reduction.objects = wsloopReductionObjects;
wsloopArgs.reduction.vars = wsloopClauseOps.reductionVars;
@@ -3528,7 +3605,7 @@ static mlir::omp::DistributeOp genCompositeDistributeParallelDoSimd(
/*useDelayedPrivatization=*/true, symTable);
parallelItemDSP.processStep1(¶llelClauseOps);
- EntryBlockArgs parallelArgs;
+ ObjectEntryBlockArgs parallelArgs;
parallelArgs.priv.objects =
makeObjects(parallelItemDSP.getDelayedPrivSymbols());
parallelArgs.priv.vars = parallelClauseOps.privateVars;
@@ -3581,13 +3658,13 @@ static mlir::omp::DistributeOp genCompositeDistributeParallelDoSimd(
iv);
// Operation creation.
- EntryBlockArgs distributeArgs;
+ ObjectEntryBlockArgs distributeArgs;
// TODO: Add private syms and vars.
auto distributeOp = genWrapperOp<mlir::omp::DistributeOp>(
converter, loc, distributeClauseOps, distributeArgs);
distributeOp.setComposite(/*val=*/true);
- EntryBlockArgs wsloopArgs;
+ ObjectEntryBlockArgs wsloopArgs;
// TODO: Add private syms and vars.
wsloopArgs.reduction.objects = wsloopReductionObjects;
wsloopArgs.reduction.vars = wsloopClauseOps.reductionVars;
@@ -3595,7 +3672,7 @@ static mlir::omp::DistributeOp genCompositeDistributeParallelDoSimd(
converter, loc, wsloopClauseOps, wsloopArgs);
wsloopOp.setComposite(/*val=*/true);
- EntryBlockArgs simdArgs;
+ ObjectEntryBlockArgs simdArgs;
simdArgs.priv.objects = makeObjects(simdItemDSP.getDelayedPrivSymbols());
simdArgs.priv.vars = simdClauseOps.privateVars;
simdArgs.reduction.objects = simdReductionObjects;
@@ -3654,7 +3731,7 @@ static mlir::omp::DistributeOp genCompositeDistributeSimd(
iv);
// Operation creation.
- EntryBlockArgs distributeArgs;
+ ObjectEntryBlockArgs distributeArgs;
distributeArgs.priv.objects =
makeObjects(distributeItemDSP.getDelayedPrivSymbols());
distributeArgs.priv.vars = distributeClauseOps.privateVars;
@@ -3662,7 +3739,7 @@ static mlir::omp::DistributeOp genCompositeDistributeSimd(
converter, loc, distributeClauseOps, distributeArgs);
distributeOp.setComposite(/*val=*/true);
- EntryBlockArgs simdArgs;
+ ObjectEntryBlockArgs simdArgs;
simdArgs.priv.objects = makeObjects(simdItemDSP.getDelayedPrivSymbols());
simdArgs.priv.vars = simdClauseOps.privateVars;
simdArgs.reduction.objects = simdReductionObjects;
@@ -3738,7 +3815,7 @@ static mlir::omp::WsloopOp genCompositeDoSimd(
iv);
// Operation creation.
- EntryBlockArgs wsloopArgs;
+ ObjectEntryBlockArgs wsloopArgs;
wsloopArgs.priv.objects = makeObjects(wsloopItemDSP.getDelayedPrivSymbols());
wsloopArgs.priv.vars = wsloopClauseOps.privateVars;
wsloopArgs.reduction.objects = wsloopReductionObjects;
@@ -3747,7 +3824,7 @@ static mlir::omp::WsloopOp genCompositeDoSimd(
converter, loc, wsloopClauseOps, wsloopArgs);
wsloopOp.setComposite(/*val=*/true);
- EntryBlockArgs simdArgs;
+ ObjectEntryBlockArgs simdArgs;
simdArgs.priv.objects = makeObjects(simdItemDSP.getDelayedPrivSymbols());
simdArgs.priv.vars = simdClauseOps.privateVars;
simdArgs.reduction.objects = simdReductionObjects;
diff --git a/flang/lib/Optimizer/OpenMP/CMakeLists.txt b/flang/lib/Optimizer/OpenMP/CMakeLists.txt
index 1e88f06456b42..db29e93b71dad 100644
--- a/flang/lib/Optimizer/OpenMP/CMakeLists.txt
+++ b/flang/lib/Optimizer/OpenMP/CMakeLists.txt
@@ -28,7 +28,6 @@ add_flang_library(FlangOpenMPTransforms
FortranSupport
HLFIRDialect
FortranUtils
- FortranEvaluate
MLIR_DEPS
${dialect_libs}
diff --git a/flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp b/flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp
index 5066c480141d0..5c70cc5c3cf76 100644
--- a/flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp
+++ b/flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp
@@ -418,7 +418,7 @@ class DoConcurrentConversion
mlir::Location loc = loop.getLoc();
auto parallelOp = mlir::omp::ParallelOp::create(rewriter, loc, parallelOps);
Fortran::common::openmp::EntryBlockArgs parallelArgs;
- parallelArgs.priv.vars = parallelOps.privateVars;
+ parallelArgs.privVars = parallelOps.privateVars;
Fortran::common::openmp::genEntryBlock(rewriter, parallelArgs,
parallelOp.getRegion());
rewriter.setInsertionPoint(mlir::omp::TerminatorOp::create(rewriter, loc));
@@ -506,8 +506,8 @@ class DoConcurrentConversion
wsloopOp.setComposite(isComposite);
Fortran::common::openmp::EntryBlockArgs wsloopArgs;
- wsloopArgs.priv.vars = wsloopClauseOps.privateVars;
- wsloopArgs.reduction.vars = wsloopClauseOps.reductionVars;
+ wsloopArgs.privVars = wsloopClauseOps.privateVars;
+ wsloopArgs.reductionVars = wsloopClauseOps.reductionVars;
Fortran::common::openmp::genEntryBlock(rewriter, wsloopArgs,
wsloopOp.getRegion());
@@ -781,7 +781,7 @@ class DoConcurrentConversion
mlir::Location loc = loop.getLoc();
auto teamsOp = mlir::omp::TeamsOp::create(rewriter, loc, teamsOps);
Fortran::common::openmp::EntryBlockArgs teamsArgs;
- teamsArgs.reduction.vars = teamsOps.reductionVars;
+ teamsArgs.reductionVars = teamsOps.reductionVars;
Fortran::common::openmp::genEntryBlock(rewriter, teamsArgs,
teamsOp.getRegion());
diff --git a/flang/lib/Optimizer/OpenMP/GenericLoopConversion.cpp b/flang/lib/Optimizer/OpenMP/GenericLoopConversion.cpp
index 0ff68eb01dab9..d2554f45c3891 100644
--- a/flang/lib/Optimizer/OpenMP/GenericLoopConversion.cpp
+++ b/flang/lib/Optimizer/OpenMP/GenericLoopConversion.cpp
@@ -272,12 +272,12 @@ class GenericLoopConversionPattern
clauseOps.privateSyms.assign(privateSyms->begin(), privateSyms->end());
Fortran::common::openmp::EntryBlockArgs args;
- args.priv.vars = clauseOps.privateVars;
+ args.privVars = clauseOps.privateVars;
if constexpr (!std::is_same_v<OpOperandsTy,
mlir::omp::DistributeOperands>) {
populateReductionClauseOps(loopOp, clauseOps);
- args.reduction.vars = clauseOps.reductionVars;
+ args.reductionVars = clauseOps.reductionVars;
}
auto wrapperOp = OpTy::create(rewriter, loopOp.getLoc(), clauseOps);
@@ -305,7 +305,7 @@ class GenericLoopConversionPattern
privateSyms->end());
Fortran::common::openmp::EntryBlockArgs parallelArgs;
- parallelArgs.priv.vars = parallelClauseOps.privateVars;
+ parallelArgs.privVars = parallelClauseOps.privateVars;
auto parallelOp = mlir::omp::ParallelOp::create(rewriter, loopOp.getLoc(),
parallelClauseOps);
@@ -323,7 +323,7 @@ class GenericLoopConversionPattern
mlir::omp::WsloopOperands wsloopClauseOps;
populateReductionClauseOps(loopOp, wsloopClauseOps);
Fortran::common::openmp::EntryBlockArgs wsloopArgs;
- wsloopArgs.reduction.vars = wsloopClauseOps.reductionVars;
+ wsloopArgs.reductionVars = wsloopClauseOps.reductionVars;
auto wsloopOp =
mlir::omp::WsloopOp::create(rewriter, loopOp.getLoc(), wsloopClauseOps);
diff --git a/flang/lib/Support/OpenMP-utils.cpp b/flang/lib/Support/OpenMP-utils.cpp
index 97e7723f0be8c..66f212a6b0b84 100644
--- a/flang/lib/Support/OpenMP-utils.cpp
+++ b/flang/lib/Support/OpenMP-utils.cpp
@@ -13,16 +13,15 @@
namespace Fortran::common::openmp {
mlir::Block *genEntryBlock(mlir::OpBuilder &builder, const EntryBlockArgs &args,
mlir::Region ®ion) {
- assert(args.isValid() && "invalid args");
assert(region.empty() && "non-empty region");
llvm::SmallVector<mlir::Type> types;
llvm::SmallVector<mlir::Location> locs;
- unsigned numVars = args.hasDeviceAddr.vars.size() + args.hostEvalVars.size() +
- args.inReduction.vars.size() + args.map.vars.size() +
- args.priv.vars.size() + args.reduction.vars.size() +
- args.taskReduction.vars.size() + args.useDeviceAddr.vars.size() +
- args.useDevicePtr.vars.size();
+ unsigned numVars = args.hasDeviceAddrVars.size() + args.hostEvalVars.size() +
+ args.inReductionVars.size() + args.mapVars.size() +
+ args.privVars.size() + args.reductionVars.size() +
+ args.taskReductionVars.size() + args.useDeviceAddrVars.size() +
+ args.useDevicePtrVars.size();
types.reserve(numVars);
locs.reserve(numVars);
@@ -35,15 +34,15 @@ mlir::Block *genEntryBlock(mlir::OpBuilder &builder, const EntryBlockArgs &args,
// Populate block arguments in clause name alphabetical order to match
// expected order by the BlockArgOpenMPOpInterface.
- extractTypeLoc(args.hasDeviceAddr.vars);
+ extractTypeLoc(args.hasDeviceAddrVars);
extractTypeLoc(args.hostEvalVars);
- extractTypeLoc(args.inReduction.vars);
- extractTypeLoc(args.map.vars);
- extractTypeLoc(args.priv.vars);
- extractTypeLoc(args.reduction.vars);
- extractTypeLoc(args.taskReduction.vars);
- extractTypeLoc(args.useDeviceAddr.vars);
- extractTypeLoc(args.useDevicePtr.vars);
+ extractTypeLoc(args.inReductionVars);
+ extractTypeLoc(args.mapVars);
+ extractTypeLoc(args.privVars);
+ extractTypeLoc(args.reductionVars);
+ extractTypeLoc(args.taskReductionVars);
+ extractTypeLoc(args.useDeviceAddrVars);
+ extractTypeLoc(args.useDevicePtrVars);
return builder.createBlock(®ion, {}, types, locs);
}
More information about the flang-commits
mailing list