Skip to content

Commit

Permalink
[Flang][OpenMP] Move assert for wrapper syms and block args to genLoo…
Browse files Browse the repository at this point in the history
…pNestOp (#103731)

This patch adds an assert to `genLoopNestClauses` to ensure the number
of symbols and corresponding loop wrapper entry block arguments have the
same size. This is checked by some of the callers, but it makes more
sense moving it into the function itself and avoid having to replicate
it.
  • Loading branch information
skatrak authored Aug 15, 2024
1 parent 7227b44 commit 3a3990c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions flang/lib/Lower/OpenMP/OpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1371,6 +1371,9 @@ genLoopNestOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
llvm::ArrayRef<const semantics::Symbol *> wrapperSyms,
llvm::ArrayRef<mlir::BlockArgument> wrapperArgs,
llvm::omp::Directive directive, DataSharingProcessor &dsp) {
assert(wrapperSyms.size() == wrapperArgs.size() &&
"Number of symbols and wrapper block arguments must match");

auto ivCallback = [&](mlir::Operation *op) {
genLoopVars(op, converter, loc, iv, wrapperSyms, wrapperArgs);
return llvm::SmallVector<const semantics::Symbol *>(iv);
Expand Down Expand Up @@ -2083,8 +2086,6 @@ static void genCompositeDistributeSimd(
llvm::concat<mlir::BlockArgument>(distributeOp.getRegion().getArguments(),
simdOp.getRegion().getArguments()));

assert(wrapperArgs.empty() &&
"Block args for omp.simd and omp.distribute currently not expected");
genLoopNestOp(converter, symTable, semaCtx, eval, loc, queue, item,
loopNestClauseOps, iv, /*wrapperSyms=*/{}, wrapperArgs,
llvm::omp::Directive::OMPD_distribute_simd, dsp);
Expand Down Expand Up @@ -2132,8 +2133,6 @@ static void genCompositeDoSimd(lower::AbstractConverter &converter,
auto wrapperArgs = llvm::to_vector(llvm::concat<mlir::BlockArgument>(
wsloopOp.getRegion().getArguments(), simdOp.getRegion().getArguments()));

assert(wsloopReductionSyms.size() == wrapperArgs.size() &&
"Number of symbols and wrapper block arguments must match");
genLoopNestOp(converter, symTable, semaCtx, eval, loc, queue, item,
loopNestClauseOps, iv, wsloopReductionSyms, wrapperArgs,
llvm::omp::Directive::OMPD_do_simd, dsp);
Expand Down

0 comments on commit 3a3990c

Please sign in to comment.