diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp index 5b2cf7930e4a3c..e1efe0d1bd2d47 100644 --- a/flang/lib/Lower/OpenMP/OpenMP.cpp +++ b/flang/lib/Lower/OpenMP/OpenMP.cpp @@ -504,11 +504,6 @@ struct OpWithBodyGenInfo { : converter(converter), symTable(symTable), semaCtx(semaCtx), loc(loc), eval(eval), dir(dir) {} - OpWithBodyGenInfo &setOuterCombined(bool value) { - outerCombined = value; - return *this; - } - OpWithBodyGenInfo &setClauses(const List *value) { clauses = value; return *this; @@ -519,14 +514,6 @@ struct OpWithBodyGenInfo { return *this; } - OpWithBodyGenInfo & - setReductions(llvm::SmallVectorImpl *value1, - llvm::SmallVectorImpl *value2) { - reductionSymbols = value1; - reductionTypes = value2; - return *this; - } - OpWithBodyGenInfo &setGenRegionEntryCb(GenOMPRegionEntryCBFn value) { genRegionEntryCB = value; return *this; @@ -544,16 +531,10 @@ struct OpWithBodyGenInfo { lower::pft::Evaluation &eval; /// [in] leaf directive for which to generate the op body. llvm::omp::Directive dir; - /// [in] is this an outer operation - prevents privatization. - bool outerCombined = false; /// [in] list of clauses to process. const List *clauses = nullptr; /// [in] if provided, processes the construct's data-sharing attributes. DataSharingProcessor *dsp = nullptr; - /// [in] if provided, list of reduction symbols - llvm::SmallVectorImpl *reductionSymbols = nullptr; - /// [in] if provided, list of reduction types - llvm::SmallVectorImpl *reductionTypes = nullptr; /// [in] if provided, emits the op's region entry. Otherwise, an emtpy block /// is created in the region. GenOMPRegionEntryCBFn genRegionEntryCB = nullptr; @@ -591,9 +572,8 @@ static void createBodyOfOp(mlir::Operation &op, const OpWithBodyGenInfo &info, // Mark the earliest insertion point. mlir::Operation *marker = insertMarker(firOpBuilder); - // If it is an unstructured region and is not the outer region of a combined - // construct, create empty blocks for all evaluations. - if (info.eval.lowerAsUnstructured() && !info.outerCombined) + // If it is an unstructured region, create empty blocks for all evaluations. + if (info.eval.lowerAsUnstructured()) lower::createEmptyRegionBlocks( firOpBuilder, info.eval.getNestedEvaluations()); @@ -601,16 +581,14 @@ static void createBodyOfOp(mlir::Operation &op, const OpWithBodyGenInfo &info, // code will use the right symbols. bool isLoop = llvm::omp::getDirectiveAssociation(info.dir) == llvm::omp::Association::Loop; - bool privatize = info.clauses && !info.outerCombined; + bool privatize = info.clauses; firOpBuilder.setInsertionPoint(marker); std::optional tempDsp; - if (privatize) { - if (!info.dsp) { - tempDsp.emplace(info.converter, info.semaCtx, *info.clauses, info.eval, - Fortran::lower::omp::isLastItemInQueue(item, queue)); - tempDsp->processStep1(); - } + if (privatize && !info.dsp) { + tempDsp.emplace(info.converter, info.semaCtx, *info.clauses, info.eval, + Fortran::lower::omp::isLastItemInQueue(item, queue)); + tempDsp->processStep1(); } if (info.dir == llvm::omp::Directive::OMPD_parallel) { @@ -1078,8 +1056,7 @@ genOrderedRegionClauses(lower::AbstractConverter &converter, static void genParallelClauses( lower::AbstractConverter &converter, semantics::SemanticsContext &semaCtx, lower::StatementContext &stmtCtx, const List &clauses, - mlir::Location loc, bool processReduction, - mlir::omp::ParallelClauseOps &clauseOps, + mlir::Location loc, mlir::omp::ParallelClauseOps &clauseOps, llvm::SmallVectorImpl &reductionTypes, llvm::SmallVectorImpl &reductionSyms) { ClauseProcessor cp(converter, semaCtx, clauses); @@ -1088,10 +1065,7 @@ static void genParallelClauses( cp.processIf(llvm::omp::Directive::OMPD_parallel, clauseOps); cp.processNumThreads(stmtCtx, clauseOps); cp.processProcBind(clauseOps); - - if (processReduction) { - cp.processReduction(loc, clauseOps, &reductionTypes, &reductionSyms); - } + cp.processReduction(loc, clauseOps, &reductionTypes, &reductionSyms); } static void genSectionsClauses(lower::AbstractConverter &converter, @@ -1440,15 +1414,13 @@ static mlir::omp::ParallelOp genParallelOp(lower::AbstractConverter &converter, lower::SymMap &symTable, semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval, mlir::Location loc, - const ConstructQueue &queue, ConstructQueue::iterator item, - bool outerCombined = false) { + const ConstructQueue &queue, ConstructQueue::iterator item) { fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder(); lower::StatementContext stmtCtx; mlir::omp::ParallelClauseOps clauseOps; llvm::SmallVector reductionTypes; llvm::SmallVector reductionSyms; - genParallelClauses(converter, semaCtx, stmtCtx, item->clauses, loc, - /*processReduction=*/!outerCombined, clauseOps, + genParallelClauses(converter, semaCtx, stmtCtx, item->clauses, loc, clauseOps, reductionTypes, reductionSyms); auto reductionCallback = [&](mlir::Operation *op) { @@ -1459,22 +1431,17 @@ genParallelOp(lower::AbstractConverter &converter, lower::SymMap &symTable, OpWithBodyGenInfo genInfo = OpWithBodyGenInfo(converter, symTable, semaCtx, loc, eval, llvm::omp::Directive::OMPD_parallel) - .setOuterCombined(outerCombined) .setClauses(&item->clauses) - .setReductions(&reductionSyms, &reductionTypes) .setGenRegionEntryCb(reductionCallback); if (!enableDelayedPrivatization) return genOpWithBody(genInfo, queue, item, clauseOps); - bool privatize = !outerCombined; DataSharingProcessor dsp(converter, semaCtx, item->clauses, eval, lower::omp::isLastItemInQueue(item, queue), /*useDelayedPrivatization=*/true, &symTable); - - if (privatize) - dsp.processStep1(&clauseOps); + dsp.processStep1(&clauseOps); auto genRegionEntryCB = [&](mlir::Operation *op) { auto parallelOp = llvm::cast(op); @@ -1921,7 +1888,7 @@ static mlir::omp::TeamsOp genTeamsOp(lower::AbstractConverter &converter, lower::SymMap &symTable, semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval, mlir::Location loc, const ConstructQueue &queue, - ConstructQueue::iterator item, bool outerCombined = false) { + ConstructQueue::iterator item) { lower::StatementContext stmtCtx; mlir::omp::TeamsClauseOps clauseOps; genTeamsClauses(converter, semaCtx, stmtCtx, item->clauses, loc, clauseOps); @@ -1929,7 +1896,6 @@ genTeamsOp(lower::AbstractConverter &converter, lower::SymMap &symTable, return genOpWithBody( OpWithBodyGenInfo(converter, symTable, semaCtx, loc, eval, llvm::omp::Directive::OMPD_teams) - .setOuterCombined(outerCombined) .setClauses(&item->clauses), queue, item, clauseOps); } @@ -1982,7 +1948,6 @@ genWsloopOp(lower::AbstractConverter &converter, lower::SymMap &symTable, *nestedEval, llvm::omp::Directive::OMPD_do) .setClauses(&item->clauses) .setDataSharingProcessor(&dsp) - .setReductions(&reductionSyms, &reductionTypes) .setGenRegionEntryCb(ivCallback), queue, item); symTable.popScope(); @@ -2084,8 +2049,7 @@ static void genOMPDispatch(lower::AbstractConverter &converter, genOrderedRegionOp(converter, symTable, semaCtx, eval, loc, queue, item); break; case llvm::omp::Directive::OMPD_parallel: - genParallelOp(converter, symTable, semaCtx, eval, loc, queue, item, - /*outerCombined=*/false); + genParallelOp(converter, symTable, semaCtx, eval, loc, queue, item); break; case llvm::omp::Directive::OMPD_section: genSectionOp(converter, symTable, semaCtx, eval, loc, queue, item);