Skip to content

Commit b8b8275

Browse files
authored
[Flang][OpenMP][Lower] Clause lowering cleanup (#103058)
This patch removes the `ClauseProcessor::processDefault` method due to it having been implemented in `DataSharingProcessor::collectDefaultSymbols` instead. Also, some `genXyzClauses` functions are updated to avoid triggering TODO errors for clauses not supported by the corresponding construct and to keep alphabetical sorting on the order in which clauses are processed.
1 parent 0d074ba commit b8b8275

File tree

3 files changed

+10
-34
lines changed

3 files changed

+10
-34
lines changed

flang/lib/Lower/OpenMP/ClauseProcessor.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -256,28 +256,6 @@ bool ClauseProcessor::processCollapse(
256256
return found;
257257
}
258258

259-
bool ClauseProcessor::processDefault() const {
260-
if (auto *clause = findUniqueClause<omp::clause::Default>()) {
261-
// Private, Firstprivate, Shared, None
262-
switch (clause->v) {
263-
case omp::clause::Default::DataSharingAttribute::Shared:
264-
case omp::clause::Default::DataSharingAttribute::None:
265-
// Default clause with shared or none do not require any handling since
266-
// Shared is the default behavior in the IR and None is only required
267-
// for semantic checks.
268-
break;
269-
case omp::clause::Default::DataSharingAttribute::Private:
270-
// TODO Support default(private)
271-
break;
272-
case omp::clause::Default::DataSharingAttribute::Firstprivate:
273-
// TODO Support default(firstprivate)
274-
break;
275-
}
276-
return true;
277-
}
278-
return false;
279-
}
280-
281259
bool ClauseProcessor::processDevice(lower::StatementContext &stmtCtx,
282260
mlir::omp::DeviceClauseOps &result) const {
283261
const parser::CharBlock *source = nullptr;

flang/lib/Lower/OpenMP/ClauseProcessor.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ class ClauseProcessor {
5757
processCollapse(mlir::Location currentLocation, lower::pft::Evaluation &eval,
5858
mlir::omp::LoopRelatedOps &result,
5959
llvm::SmallVectorImpl<const semantics::Symbol *> &iv) const;
60-
bool processDefault() const;
6160
bool processDevice(lower::StatementContext &stmtCtx,
6261
mlir::omp::DeviceClauseOps &result) const;
6362
bool processDeviceType(mlir::omp::DeviceTypeClauseOps &result) const;

flang/lib/Lower/OpenMP/OpenMP.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,8 +1055,9 @@ static void genFlushClauses(lower::AbstractConverter &converter,
10551055
if (!objects.empty())
10561056
genObjectList(objects, converter, operandRange);
10571057

1058-
if (!clauses.empty())
1059-
TODO(converter.getCurrentLocation(), "Handle OmpMemoryOrderClause");
1058+
ClauseProcessor cp(converter, semaCtx, clauses);
1059+
cp.processTODO<clause::AcqRel, clause::Acquire, clause::Release,
1060+
clause::SeqCst>(loc, llvm::omp::OMPD_flush);
10601061
}
10611062

10621063
static void
@@ -1096,7 +1097,6 @@ static void genParallelClauses(
10961097
llvm::SmallVectorImpl<const semantics::Symbol *> &reductionSyms) {
10971098
ClauseProcessor cp(converter, semaCtx, clauses);
10981099
cp.processAllocate(clauseOps);
1099-
cp.processDefault();
11001100
cp.processIf(llvm::omp::Directive::OMPD_parallel, clauseOps);
11011101
cp.processNumThreads(stmtCtx, clauseOps);
11021102
cp.processProcBind(clauseOps);
@@ -1129,7 +1129,7 @@ static void genSimdClauses(lower::AbstractConverter &converter,
11291129
cp.processSimdlen(clauseOps);
11301130

11311131
// TODO Support delayed privatization.
1132-
cp.processTODO<clause::Allocate, clause::Linear, clause::Nontemporal>(
1132+
cp.processTODO<clause::Linear, clause::Nontemporal>(
11331133
loc, llvm::omp::Directive::OMPD_simd);
11341134
}
11351135

@@ -1167,15 +1167,15 @@ static void genTargetClauses(
11671167
cp.processIsDevicePtr(clauseOps, devicePtrTypes, devicePtrLocs,
11681168
devicePtrSyms);
11691169
cp.processMap(loc, stmtCtx, clauseOps, &mapSyms, &mapLocs, &mapTypes);
1170-
cp.processThreadLimit(stmtCtx, clauseOps);
11711170

11721171
if (processHostOnlyClauses)
11731172
cp.processNowait(clauseOps);
11741173

1174+
cp.processThreadLimit(stmtCtx, clauseOps);
1175+
11751176
cp.processTODO<clause::Allocate, clause::Defaultmap, clause::Firstprivate,
1176-
clause::InReduction, clause::Reduction,
1177-
clause::UsesAllocators>(loc,
1178-
llvm::omp::Directive::OMPD_target);
1177+
clause::InReduction, clause::UsesAllocators>(
1178+
loc, llvm::omp::Directive::OMPD_target);
11791179

11801180
// `target private(..)` is only supported in delayed privatization mode.
11811181
if (!enableDelayedPrivatizationStaging)
@@ -1223,14 +1223,15 @@ static void genTargetEnterExitUpdateDataClauses(
12231223
cp.processDepend(clauseOps);
12241224
cp.processDevice(stmtCtx, clauseOps);
12251225
cp.processIf(directive, clauseOps);
1226-
cp.processNowait(clauseOps);
12271226

12281227
if (directive == llvm::omp::Directive::OMPD_target_update) {
12291228
cp.processMotionClauses<clause::To>(stmtCtx, clauseOps);
12301229
cp.processMotionClauses<clause::From>(stmtCtx, clauseOps);
12311230
} else {
12321231
cp.processMap(loc, stmtCtx, clauseOps);
12331232
}
1233+
1234+
cp.processNowait(clauseOps);
12341235
}
12351236

12361237
static void genTaskClauses(lower::AbstractConverter &converter,
@@ -1240,7 +1241,6 @@ static void genTaskClauses(lower::AbstractConverter &converter,
12401241
mlir::omp::TaskOperands &clauseOps) {
12411242
ClauseProcessor cp(converter, semaCtx, clauses);
12421243
cp.processAllocate(clauseOps);
1243-
cp.processDefault();
12441244
cp.processDepend(clauseOps);
12451245
cp.processFinal(stmtCtx, clauseOps);
12461246
cp.processIf(llvm::omp::Directive::OMPD_task, clauseOps);
@@ -1279,7 +1279,6 @@ static void genTeamsClauses(lower::AbstractConverter &converter,
12791279
mlir::omp::TeamsOperands &clauseOps) {
12801280
ClauseProcessor cp(converter, semaCtx, clauses);
12811281
cp.processAllocate(clauseOps);
1282-
cp.processDefault();
12831282
cp.processIf(llvm::omp::Directive::OMPD_teams, clauseOps);
12841283
cp.processNumTeams(stmtCtx, clauseOps);
12851284
cp.processThreadLimit(stmtCtx, clauseOps);

0 commit comments

Comments
 (0)