[flang][OpenMP] fix predetermined privatization inside section (#138159)
This now produces code equivalent to if there was an explicit private clause on the SECTIONS construct. The problem was that each SECTION construct got its own DSP, which tried to privatize the same symbol for that SECTION. Privatization for SECTION(S) happens on the outer SECTION construct and so the outer construct's DSP should be shared. Fixes #135108
This commit is contained in:
@@ -67,6 +67,8 @@ void DataSharingProcessor::processStep1(
|
||||
|
||||
void DataSharingProcessor::processStep2(mlir::Operation *op, bool isLoop) {
|
||||
// 'sections' lastprivate is handled by genOMP()
|
||||
if (mlir::isa<mlir::omp::SectionOp>(op))
|
||||
return;
|
||||
if (!mlir::isa<mlir::omp::SectionsOp>(op)) {
|
||||
mlir::OpBuilder::InsertionGuard guard(firOpBuilder);
|
||||
copyLastPrivatize(op);
|
||||
|
||||
@@ -2154,6 +2154,7 @@ genSectionsOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
|
||||
OpWithBodyGenInfo(converter, symTable, semaCtx, loc, nestedEval,
|
||||
llvm::omp::Directive::OMPD_section)
|
||||
.setClauses(§ionQueue.begin()->clauses)
|
||||
.setDataSharingProcessor(&dsp)
|
||||
.setEntryBlockArgs(&args),
|
||||
sectionQueue, sectionQueue.begin());
|
||||
}
|
||||
|
||||
34
flang/test/Lower/OpenMP/sections-predetermined-private.f90
Normal file
34
flang/test/Lower/OpenMP/sections-predetermined-private.f90
Normal file
@@ -0,0 +1,34 @@
|
||||
! RUN: %flang_fc1 -fopenmp -emit-hlfir -o - %s | FileCheck %s
|
||||
|
||||
!$omp parallel sections
|
||||
!$omp section
|
||||
do i = 1, 2
|
||||
end do
|
||||
!$omp section
|
||||
do i = 1, 2
|
||||
end do
|
||||
!$omp end parallel sections
|
||||
end
|
||||
! CHECK-LABEL: func.func @_QQmain() {
|
||||
! CHECK: omp.parallel {
|
||||
! CHECK: %[[VAL_3:.*]] = fir.alloca i32 {bindc_name = "i", pinned}
|
||||
! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %[[VAL_3]] {uniq_name = "_QFEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
|
||||
! CHECK: omp.sections {
|
||||
! CHECK: omp.section {
|
||||
! CHECK: %[[VAL_11:.*]]:2 = fir.do_loop %[[VAL_12:.*]] = %{{.*}} to %{{.*}} step %{{.*}} iter_args(%{{.*}} = %{{.*}} -> (index, i32) {
|
||||
! CHECK: }
|
||||
! CHECK: fir.store %[[VAL_11]]#1 to %[[VAL_4]]#0 : !fir.ref<i32>
|
||||
! CHECK: omp.terminator
|
||||
! CHECK: }
|
||||
! CHECK: omp.section {
|
||||
! CHECK: %[[VAL_25:.*]]:2 = fir.do_loop %[[VAL_26:.*]] = %{{.*}} to %{{.*}} step %{{.*}} iter_args(%{{.*}} = %{{.*}}) -> (index, i32) {
|
||||
! CHECK: }
|
||||
! CHECK: fir.store %[[VAL_25]]#1 to %[[VAL_4]]#0 : !fir.ref<i32>
|
||||
! CHECK: omp.terminator
|
||||
! CHECK: }
|
||||
! CHECK: omp.terminator
|
||||
! CHECK: }
|
||||
! CHECK: omp.terminator
|
||||
! CHECK: }
|
||||
! CHECK: return
|
||||
! CHECK: }
|
||||
Reference in New Issue
Block a user