@@ -201,6 +201,8 @@ class HostEvalInfo {
201
201
// / structures, but it will probably still require some further work to support
202
202
// / reverse offloading.
203
203
static llvm::SmallVector<HostEvalInfo, 0 > hostEvalInfo;
204
+ static llvm::SmallVector<const parser::OpenMPSectionsConstruct *, 0 >
205
+ sectionsStack;
204
206
205
207
// / Bind symbols to their corresponding entry block arguments.
206
208
// /
@@ -2220,8 +2222,12 @@ static mlir::omp::SectionsOp
2220
2222
genSectionsOp (lower::AbstractConverter &converter, lower::SymMap &symTable,
2221
2223
semantics::SemanticsContext &semaCtx,
2222
2224
lower::pft::Evaluation &eval, mlir::Location loc,
2223
- const ConstructQueue &queue, ConstructQueue::const_iterator item,
2224
- const parser::OmpSectionBlocks §ionBlocks) {
2225
+ const ConstructQueue &queue,
2226
+ ConstructQueue::const_iterator item) {
2227
+ assert (!sectionsStack.empty ());
2228
+ const auto §ionBlocks =
2229
+ std::get<parser::OmpSectionBlocks>(sectionsStack.back ()->t );
2230
+ sectionsStack.pop_back ();
2225
2231
mlir::omp::SectionsOperands clauseOps;
2226
2232
llvm::SmallVector<const semantics::Symbol *> reductionSyms;
2227
2233
genSectionsClauses (converter, semaCtx, item->clauses , loc, clauseOps,
@@ -3458,10 +3464,7 @@ static void genOMPDispatch(lower::AbstractConverter &converter,
3458
3464
// Lowered in the enclosing genSectionsOp.
3459
3465
break ;
3460
3466
case llvm::omp::Directive::OMPD_sections:
3461
- // Called directly from genOMP([...], OpenMPSectionsConstruct) because it
3462
- // has a different prototype.
3463
- // This code path is still taken when iterating through the construct queue
3464
- // in genBodyOfOp
3467
+ genSectionsOp (converter, symTable, semaCtx, eval, loc, queue, item);
3465
3468
break ;
3466
3469
case llvm::omp::Directive::OMPD_simd:
3467
3470
newOp =
@@ -4137,8 +4140,6 @@ static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
4137
4140
std::get<parser::OmpClauseList>(beginSectionsDirective.t ), semaCtx);
4138
4141
const auto &endSectionsDirective =
4139
4142
std::get<parser::OmpEndSectionsDirective>(sectionsConstruct.t );
4140
- const auto §ionBlocks =
4141
- std::get<parser::OmpSectionBlocks>(sectionsConstruct.t );
4142
4143
clauses.append (makeClauses (
4143
4144
std::get<parser::OmpClauseList>(endSectionsDirective.t ), semaCtx));
4144
4145
mlir::Location currentLocation = converter.getCurrentLocation ();
@@ -4150,22 +4151,10 @@ static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
4150
4151
ConstructQueue queue{
4151
4152
buildConstructQueue (converter.getFirOpBuilder ().getModule (), semaCtx,
4152
4153
eval, source, directive, clauses)};
4153
- ConstructQueue::iterator next = queue.begin ();
4154
- // Generate constructs that come first e.g. Parallel
4155
- while (next != queue.end () &&
4156
- next->id != llvm::omp::Directive::OMPD_sections) {
4157
- genOMPDispatch (converter, symTable, semaCtx, eval, currentLocation, queue,
4158
- next);
4159
- next = std::next (next);
4160
- }
4161
4154
4162
- // call genSectionsOp directly (not via genOMPDispatch) so that we can add the
4163
- // sectionBlocks argument
4164
- assert (next != queue.end ());
4165
- assert (next->id == llvm::omp::Directive::OMPD_sections);
4166
- genSectionsOp (converter, symTable, semaCtx, eval, currentLocation, queue,
4167
- next, sectionBlocks);
4168
- assert (std::next (next) == queue.end ());
4155
+ sectionsStack.push_back (§ionsConstruct);
4156
+ genOMPDispatch (converter, symTable, semaCtx, eval, currentLocation, queue,
4157
+ queue.begin ());
4169
4158
}
4170
4159
4171
4160
static void genOMP (lower::AbstractConverter &converter, lower::SymMap &symTable,
0 commit comments