@@ -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,
@@ -3462,6 +3468,7 @@ static void genOMPDispatch(lower::AbstractConverter &converter,
3462
3468
// has a different prototype.
3463
3469
// This code path is still taken when iterating through the construct queue
3464
3470
// in genBodyOfOp
3471
+ genSectionsOp (converter, symTable, semaCtx, eval, loc, queue, item);
3465
3472
break ;
3466
3473
case llvm::omp::Directive::OMPD_simd:
3467
3474
newOp =
@@ -4137,8 +4144,6 @@ static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
4137
4144
std::get<parser::OmpClauseList>(beginSectionsDirective.t ), semaCtx);
4138
4145
const auto &endSectionsDirective =
4139
4146
std::get<parser::OmpEndSectionsDirective>(sectionsConstruct.t );
4140
- const auto §ionBlocks =
4141
- std::get<parser::OmpSectionBlocks>(sectionsConstruct.t );
4142
4147
clauses.append (makeClauses (
4143
4148
std::get<parser::OmpClauseList>(endSectionsDirective.t ), semaCtx));
4144
4149
mlir::Location currentLocation = converter.getCurrentLocation ();
@@ -4150,22 +4155,10 @@ static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
4150
4155
ConstructQueue queue{
4151
4156
buildConstructQueue (converter.getFirOpBuilder ().getModule (), semaCtx,
4152
4157
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
4158
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 ());
4159
+ sectionsStack.push_back (§ionsConstruct);
4160
+ genOMPDispatch (converter, symTable, semaCtx, eval, currentLocation, queue,
4161
+ queue.begin ());
4169
4162
}
4170
4163
4171
4164
static void genOMP (lower::AbstractConverter &converter, lower::SymMap &symTable,
0 commit comments