Skip to content

Commit e1aa8ad

Browse files
authored
[flang][OpenMP] Fix bug in emitting dealloc logic (#93641)
Fixes a bug in emiting deacllocation logic when delayed privatization is disabled. I introduced the bug when implementing delayed privatization for allocatables: when delayed privatization is disabled the deacllocation ops are emitted for only one allocatable variables.
1 parent 78cc9cb commit e1aa8ad

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

flang/lib/Lower/OpenMP/DataSharingProcessor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void DataSharingProcessor::insertDeallocs() {
8686
if (semantics::IsAllocatable(sym->GetUltimate())) {
8787
if (!useDelayedPrivatization) {
8888
converter.createHostAssociateVarCloneDealloc(*sym);
89-
return;
89+
continue;
9090
}
9191

9292
lower::SymbolBox hsb = converter.lookupOneLevelUpSymbol(*sym);
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
! Test early privatization for multiple allocatable variables.
2+
3+
! RUN: %flang_fc1 -emit-hlfir -fopenmp -mmlir --openmp-enable-delayed-privatization=false \
4+
! RUN: -o - %s 2>&1 | FileCheck %s
5+
6+
! RUN: bbc -emit-hlfir -fopenmp --openmp-enable-delayed-privatization=false -o - %s 2>&1 |\
7+
! RUN: FileCheck %s
8+
9+
subroutine delayed_privatization_allocatable
10+
implicit none
11+
integer, allocatable :: var1, var2
12+
13+
!$omp parallel private(var1, var2)
14+
var1 = 10
15+
var2 = 20
16+
!$omp end parallel
17+
end subroutine
18+
19+
! Verify that private versions of each variable are both allocated and freed
20+
! within the parallel region.
21+
22+
! CHECK: omp.parallel {
23+
! CHECK: fir.allocmem
24+
! CHECK: fir.allocmem
25+
! CHECK: fir.freemem
26+
! CHECK: fir.freemem
27+
! CHECK: omp.terminator
28+
! CHECK-NEXT: }

0 commit comments

Comments
 (0)