Skip to content

Commit 0b8b37b

Browse files
committed
[flang][OpenMP] Put taskgroup in a new scope
Although taskgroup is a privatizing construct, because of task_reduction clause, a new scope was not being created for it. This could cause an extra privatization of variables when taskgroup was lowered, because its scope would be the same as of the parent privatizing construct. This fixes regressions in tests 1052_0201 and 1052_0205, from Fujitsu testsuite. This issue didn't happen before because implicit symbols were being created in a different way before llvm#142154.
1 parent fb761aa commit 0b8b37b

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

flang/lib/Semantics/resolve-names.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1729,7 +1729,6 @@ bool OmpVisitor::NeedsScope(const parser::OpenMPBlockConstruct &x) {
17291729
switch (beginDir.v) {
17301730
case llvm::omp::Directive::OMPD_master:
17311731
case llvm::omp::Directive::OMPD_ordered:
1732-
case llvm::omp::Directive::OMPD_taskgroup:
17331732
return false;
17341733
default:
17351734
return true;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
! RUN: %flang_fc1 -emit-hlfir -fopenmp -o - %s 2>&1 | FileCheck %s
2+
3+
! Check that variables are not privatized twice when TASKGROUP is used.
4+
5+
!CHECK-LABEL: func.func @_QPsub() {
6+
!CHECK: omp.parallel {
7+
!CHECK: %[[PAR_I:.*]]:2 = hlfir.declare %{{.*}} {uniq_name = "_QFsubEi"}
8+
!CHECK: omp.master {
9+
!CHECK: omp.taskgroup {
10+
!CHECK-NEXT: omp.task private(@_QFsubEi_firstprivate_i32 %[[PAR_I]]#0 -> %[[TASK_I:.*]] : !fir.ref<i32>) {
11+
!CHECK: %[[TASK_I_DECL:.*]]:2 = hlfir.declare %[[TASK_I]] {uniq_name = "_QFsubEi"}
12+
!CHECK: }
13+
!CHECK: }
14+
!CHECK: }
15+
!CHECK: }
16+
17+
subroutine sub()
18+
integer, dimension(10) :: a
19+
integer :: i
20+
21+
!$omp parallel
22+
!$omp master
23+
do i=1,10
24+
!$omp taskgroup
25+
!$omp task shared(a)
26+
a(i) = 1
27+
!$omp end task
28+
!$omp end taskgroup
29+
end do
30+
!$omp end master
31+
!$omp end parallel
32+
end subroutine

0 commit comments

Comments
 (0)