Skip to content

Commit c44860c

Browse files
authored
[Flang][OpenMP] Disable lowering of omp.simd reductions in composites (#112686)
Currently, the `omp.simd` operation is ignored during MLIR to LLVM IR translation when it takes part in a composite construct. One consequence of this limitation is that any entry block arguments defined by that operation will trigger a compiler crash if they are used anywhere, as they are not bound to an LLVM IR value. A previous PR introducing support for the `reduction` clause resulted in the creation and use of entry block arguments attached to the `omp.simd` operation, causing compiler crashes on 'do simd reduction(...)' constructs. This patch disables Flang lowering of simd reductions in 'do simd' constructs to avoid triggering these errors while translation to LLVM IR is still incomplete.
1 parent ecfeacd commit c44860c

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

flang/lib/Lower/OpenMP/OpenMP.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2209,6 +2209,12 @@ static void genCompositeDistributeParallelDoSimd(
22092209
genSimdClauses(converter, semaCtx, simdItem->clauses, loc, simdClauseOps,
22102210
simdReductionSyms);
22112211

2212+
// TODO: Remove this after omp.simd reductions on composite constructs are
2213+
// supported.
2214+
simdClauseOps.reductionVars.clear();
2215+
simdClauseOps.reductionByref.clear();
2216+
simdClauseOps.reductionSyms.clear();
2217+
22122218
mlir::omp::LoopNestOperands loopNestClauseOps;
22132219
llvm::SmallVector<const semantics::Symbol *> iv;
22142220
genLoopNestClauses(converter, semaCtx, eval, simdItem->clauses, loc,
@@ -2230,9 +2236,7 @@ static void genCompositeDistributeParallelDoSimd(
22302236
wsloopOp.setComposite(/*val=*/true);
22312237

22322238
EntryBlockArgs simdArgs;
2233-
// TODO: Add private syms and vars.
2234-
simdArgs.reduction.syms = simdReductionSyms;
2235-
simdArgs.reduction.vars = simdClauseOps.reductionVars;
2239+
// TODO: Add private and reduction syms and vars.
22362240
auto simdOp =
22372241
genWrapperOp<mlir::omp::SimdOp>(converter, loc, simdClauseOps, simdArgs);
22382242
simdOp.setComposite(/*val=*/true);
@@ -2325,6 +2329,12 @@ static void genCompositeDoSimd(lower::AbstractConverter &converter,
23252329
genSimdClauses(converter, semaCtx, simdItem->clauses, loc, simdClauseOps,
23262330
simdReductionSyms);
23272331

2332+
// TODO: Remove this after omp.simd reductions on composite constructs are
2333+
// supported.
2334+
simdClauseOps.reductionVars.clear();
2335+
simdClauseOps.reductionByref.clear();
2336+
simdClauseOps.reductionSyms.clear();
2337+
23282338
// TODO: Support delayed privatization.
23292339
DataSharingProcessor dsp(converter, semaCtx, simdItem->clauses, eval,
23302340
/*shouldCollectPreDeterminedSymbols=*/true,
@@ -2348,9 +2358,7 @@ static void genCompositeDoSimd(lower::AbstractConverter &converter,
23482358
wsloopOp.setComposite(/*val=*/true);
23492359

23502360
EntryBlockArgs simdArgs;
2351-
// TODO: Add private syms and vars.
2352-
simdArgs.reduction.syms = simdReductionSyms;
2353-
simdArgs.reduction.vars = simdClauseOps.reductionVars;
2361+
// TODO: Add private and reduction syms and vars.
23542362
auto simdOp =
23552363
genWrapperOp<mlir::omp::SimdOp>(converter, loc, simdClauseOps, simdArgs);
23562364
simdOp.setComposite(/*val=*/true);

0 commit comments

Comments
 (0)