Skip to content

[flang][OpenMP] Fix bug in emitting dealloc logic #93641

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void DataSharingProcessor::insertDeallocs() {
if (semantics::IsAllocatable(sym->GetUltimate())) {
if (!useDelayedPrivatization) {
converter.createHostAssociateVarCloneDealloc(*sym);
return;
continue;
}

lower::SymbolBox hsb = converter.lookupOneLevelUpSymbol(*sym);
Expand Down
28 changes: 28 additions & 0 deletions flang/test/Lower/OpenMP/allocatable-multiple-vars.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
! Test early privatization for multiple allocatable variables.

! RUN: %flang_fc1 -emit-hlfir -fopenmp -mmlir --openmp-enable-delayed-privatization=false \
! RUN: -o - %s 2>&1 | FileCheck %s

! RUN: bbc -emit-hlfir -fopenmp --openmp-enable-delayed-privatization=false -o - %s 2>&1 |\
! RUN: FileCheck %s

subroutine delayed_privatization_allocatable
implicit none
integer, allocatable :: var1, var2

!$omp parallel private(var1, var2)
var1 = 10
var2 = 20
!$omp end parallel
end subroutine

! Verify that private versions of each variable are both allocated and freed
! within the parallel region.

! CHECK: omp.parallel {
! CHECK: fir.allocmem
! CHECK: fir.allocmem
! CHECK: fir.freemem
! CHECK: fir.freemem
! CHECK: omp.terminator
! CHECK-NEXT: }
Loading