[flang-commits] [flang] [Flang][OpenMP] Disable lowering of omp.simd reductions in composites (PR #112686)
Sergio Afonso via flang-commits
flang-commits at lists.llvm.org
Thu Oct 17 03:08:43 PDT 2024
https://github.com/skatrak created https://github.com/llvm/llvm-project/pull/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.
>From f5b92ae7ea9d0b3dea6f57b4eb8e4071e981d47a Mon Sep 17 00:00:00 2001
From: Sergio Afonso <safonsof at amd.com>
Date: Thu, 17 Oct 2024 10:48:38 +0100
Subject: [PATCH] [Flang][OpenMP] Disable lowering of omp.simd reductions in
composites
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
associated to an LLVM IR value at any point.
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.
---
flang/lib/Lower/OpenMP/OpenMP.cpp | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp
index cf469003b7298d..52a077cd5a797a 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -2209,6 +2209,12 @@ static void genCompositeDistributeParallelDoSimd(
genSimdClauses(converter, semaCtx, simdItem->clauses, loc, simdClauseOps,
simdReductionSyms);
+ // TODO: Remove this after omp.simd reductions on composite constructs are
+ // supported.
+ simdClauseOps.reductionVars.clear();
+ simdClauseOps.reductionByref.clear();
+ simdClauseOps.reductionSyms.clear();
+
mlir::omp::LoopNestOperands loopNestClauseOps;
llvm::SmallVector<const semantics::Symbol *> iv;
genLoopNestClauses(converter, semaCtx, eval, simdItem->clauses, loc,
@@ -2230,9 +2236,7 @@ static void genCompositeDistributeParallelDoSimd(
wsloopOp.setComposite(/*val=*/true);
EntryBlockArgs simdArgs;
- // TODO: Add private syms and vars.
- simdArgs.reduction.syms = simdReductionSyms;
- simdArgs.reduction.vars = simdClauseOps.reductionVars;
+ // TODO: Add private and reduction syms and vars.
auto simdOp =
genWrapperOp<mlir::omp::SimdOp>(converter, loc, simdClauseOps, simdArgs);
simdOp.setComposite(/*val=*/true);
@@ -2325,6 +2329,12 @@ static void genCompositeDoSimd(lower::AbstractConverter &converter,
genSimdClauses(converter, semaCtx, simdItem->clauses, loc, simdClauseOps,
simdReductionSyms);
+ // TODO: Remove this after omp.simd reductions on composite constructs are
+ // supported.
+ simdClauseOps.reductionVars.clear();
+ simdClauseOps.reductionByref.clear();
+ simdClauseOps.reductionSyms.clear();
+
// TODO: Support delayed privatization.
DataSharingProcessor dsp(converter, semaCtx, simdItem->clauses, eval,
/*shouldCollectPreDeterminedSymbols=*/true,
@@ -2348,9 +2358,7 @@ static void genCompositeDoSimd(lower::AbstractConverter &converter,
wsloopOp.setComposite(/*val=*/true);
EntryBlockArgs simdArgs;
- // TODO: Add private syms and vars.
- simdArgs.reduction.syms = simdReductionSyms;
- simdArgs.reduction.vars = simdClauseOps.reductionVars;
+ // TODO: Add private and reduction syms and vars.
auto simdOp =
genWrapperOp<mlir::omp::SimdOp>(converter, loc, simdClauseOps, simdArgs);
simdOp.setComposite(/*val=*/true);
More information about the flang-commits
mailing list