Skip to content

Commit 6192fc9

Browse files
committed
Revert "[flang][OpenMP] Support MLIR lowering of linear clause for omp.wsloop (llvm#139385)"
compile assertion on rush-larsen and flang-446525 This reverts commit 0baacd1.
1 parent fccbf21 commit 6192fc9

File tree

10 files changed

+19
-385
lines changed

10 files changed

+19
-385
lines changed

flang/lib/Lower/OpenMP/ClauseProcessor.cpp

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,40 +1081,6 @@ bool ClauseProcessor::processIsDevicePtr(
10811081
});
10821082
}
10831083

1084-
bool ClauseProcessor::processLinear(mlir::omp::LinearClauseOps &result) const {
1085-
lower::StatementContext stmtCtx;
1086-
return findRepeatableClause<
1087-
omp::clause::Linear>([&](const omp::clause::Linear &clause,
1088-
const parser::CharBlock &) {
1089-
auto &objects = std::get<omp::ObjectList>(clause.t);
1090-
for (const omp::Object &object : objects) {
1091-
semantics::Symbol *sym = object.sym();
1092-
const mlir::Value variable = converter.getSymbolAddress(*sym);
1093-
result.linearVars.push_back(variable);
1094-
}
1095-
if (objects.size()) {
1096-
if (auto &mod =
1097-
std::get<std::optional<omp::clause::Linear::StepComplexModifier>>(
1098-
clause.t)) {
1099-
mlir::Value operand =
1100-
fir::getBase(converter.genExprValue(toEvExpr(*mod), stmtCtx));
1101-
result.linearStepVars.append(objects.size(), operand);
1102-
} else if (std::get<std::optional<omp::clause::Linear::LinearModifier>>(
1103-
clause.t)) {
1104-
mlir::Location currentLocation = converter.getCurrentLocation();
1105-
TODO(currentLocation, "Linear modifiers not yet implemented");
1106-
} else {
1107-
// If nothing is present, add the default step of 1.
1108-
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
1109-
mlir::Location currentLocation = converter.getCurrentLocation();
1110-
mlir::Value operand = firOpBuilder.createIntegerConstant(
1111-
currentLocation, firOpBuilder.getI32Type(), 1);
1112-
result.linearStepVars.append(objects.size(), operand);
1113-
}
1114-
}
1115-
});
1116-
}
1117-
11181084
bool ClauseProcessor::processLink(
11191085
llvm::SmallVectorImpl<DeclareTargetCapturePair> &result) const {
11201086
return findRepeatableClause<omp::clause::Link>(

flang/lib/Lower/OpenMP/ClauseProcessor.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ class ClauseProcessor {
128128
bool processIsDevicePtr(
129129
mlir::omp::IsDevicePtrClauseOps &result,
130130
llvm::SmallVectorImpl<const semantics::Symbol *> &isDeviceSyms) const;
131-
bool processLinear(mlir::omp::LinearClauseOps &result) const;
132131
bool
133132
processLink(llvm::SmallVectorImpl<DeclareTargetCapturePair> &result) const;
134133

flang/lib/Lower/OpenMP/DataSharingProcessor.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,14 @@ void DataSharingProcessor::collectSymbolsForPrivatization() {
218218
// so, we won't need to explicitely handle block objects (or forget to do
219219
// so).
220220
for (auto *sym : explicitlyPrivatizedSymbols)
221-
if (!sym->test(Fortran::semantics::Symbol::Flag::OmpLinear))
222-
allPrivatizedSymbols.insert(sym);
221+
allPrivatizedSymbols.insert(sym);
223222
}
224223

225224
bool DataSharingProcessor::needBarrier() {
226225
// Emit implicit barrier to synchronize threads and avoid data races on
227226
// initialization of firstprivate variables and post-update of lastprivate
228227
// variables.
229-
// Emit implicit barrier for linear clause in the OpenMPIRBuilder.
228+
// Emit implicit barrier for linear clause. Maybe on somewhere else.
230229
for (const semantics::Symbol *sym : allPrivatizedSymbols) {
231230
if (sym->test(semantics::Symbol::Flag::OmpLastPrivate) &&
232231
(sym->test(semantics::Symbol::Flag::OmpFirstPrivate) ||

flang/lib/Lower/OpenMP/OpenMP.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1870,13 +1870,13 @@ static void genWsloopClauses(
18701870
llvm::SmallVectorImpl<const semantics::Symbol *> &reductionSyms) {
18711871
ClauseProcessor cp(converter, semaCtx, clauses);
18721872
cp.processNowait(clauseOps);
1873-
cp.processLinear(clauseOps);
18741873
cp.processOrder(clauseOps);
18751874
cp.processOrdered(clauseOps);
18761875
cp.processReduction(loc, clauseOps, reductionSyms);
18771876
cp.processSchedule(stmtCtx, clauseOps);
18781877

1879-
cp.processTODO<clause::Allocate>(loc, llvm::omp::Directive::OMPD_do);
1878+
cp.processTODO<clause::Allocate, clause::Linear>(
1879+
loc, llvm::omp::Directive::OMPD_do);
18801880
}
18811881

18821882
//===----------------------------------------------------------------------===//

flang/test/Lower/OpenMP/wsloop-linear.f90

Lines changed: 0 additions & 57 deletions
This file was deleted.

llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3595,9 +3595,6 @@ class CanonicalLoopInfo {
35953595
BasicBlock *Latch = nullptr;
35963596
BasicBlock *Exit = nullptr;
35973597

3598-
// Hold the MLIR value for the `lastiter` of the canonical loop.
3599-
Value *LastIter = nullptr;
3600-
36013598
/// Add the control blocks of this loop to \p BBs.
36023599
///
36033600
/// This does not include any block from the body, including the one returned
@@ -3630,18 +3627,6 @@ class CanonicalLoopInfo {
36303627
void mapIndVar(llvm::function_ref<Value *(Instruction *)> Updater);
36313628

36323629
public:
3633-
/// Sets the last iteration variable for this loop.
3634-
void setLastIter(Value *IterVar) { LastIter = std::move(IterVar); }
3635-
3636-
/// Returns the last iteration variable for this loop.
3637-
/// Certain use-cases (like translation of linear clause) may access
3638-
/// this variable even after a loop transformation. Hence, do not guard
3639-
/// this getter function by `isValid`. It is the responsibility of the
3640-
/// callee to ensure this functionality is not invoked by a non-outlined
3641-
/// CanonicalLoopInfo object (in which case, `setLastIter` will never be
3642-
/// invoked and `LastIter` will be by default `nullptr`).
3643-
Value *getLastIter() { return LastIter; }
3644-
36453630
/// Returns whether this object currently represents the IR of a loop. If
36463631
/// returning false, it may have been consumed by a loop transformation or not
36473632
/// been intialized. Do not use in this case;

llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4287,7 +4287,6 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::applyStaticWorkshareLoop(
42874287
Value *PLowerBound = Builder.CreateAlloca(IVTy, nullptr, "p.lowerbound");
42884288
Value *PUpperBound = Builder.CreateAlloca(IVTy, nullptr, "p.upperbound");
42894289
Value *PStride = Builder.CreateAlloca(IVTy, nullptr, "p.stride");
4290-
CLI->setLastIter(PLastIter);
42914290

42924291
// At the end of the preheader, prepare for calling the "init" function by
42934292
// storing the current loop bounds into the allocated space. A canonical loop
@@ -4396,7 +4395,6 @@ OpenMPIRBuilder::applyStaticChunkedWorkshareLoop(DebugLoc DL,
43964395
Value *PUpperBound =
43974396
Builder.CreateAlloca(InternalIVTy, nullptr, "p.upperbound");
43984397
Value *PStride = Builder.CreateAlloca(InternalIVTy, nullptr, "p.stride");
4399-
CLI->setLastIter(PLastIter);
44004398

44014399
// Set up the source location value for the OpenMP runtime.
44024400
Builder.restoreIP(CLI->getPreheaderIP());
@@ -4880,7 +4878,6 @@ OpenMPIRBuilder::applyDynamicWorkshareLoop(DebugLoc DL, CanonicalLoopInfo *CLI,
48804878
Value *PLowerBound = Builder.CreateAlloca(IVTy, nullptr, "p.lowerbound");
48814879
Value *PUpperBound = Builder.CreateAlloca(IVTy, nullptr, "p.upperbound");
48824880
Value *PStride = Builder.CreateAlloca(IVTy, nullptr, "p.stride");
4883-
CLI->setLastIter(PLastIter);
48844881

48854882
// At the end of the preheader, prepare for calling the "init" function by
48864883
// storing the current loop bounds into the allocated space. A canonical loop

0 commit comments

Comments
 (0)