[flang-commits] [flang] [flang][OpenMP] Fix bug in emitting `dealloc` logic (PR #93641)
via flang-commits
flang-commits at lists.llvm.org
Tue May 28 21:12:45 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-fir-hlfir
Author: Kareem Ergawy (ergawy)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/93641.diff
2 Files Affected:
- (modified) flang/lib/Lower/OpenMP/DataSharingProcessor.cpp (+1-1)
- (added) flang/test/Lower/OpenMP/allocatable-multiple-vars.f90 (+25)
``````````diff
diff --git a/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp b/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
index b722e19272ca1..557a9685024c5 100644
--- a/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
@@ -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);
diff --git a/flang/test/Lower/OpenMP/allocatable-multiple-vars.f90 b/flang/test/Lower/OpenMP/allocatable-multiple-vars.f90
new file mode 100644
index 0000000000000..325d3d2c59bc7
--- /dev/null
+++ b/flang/test/Lower/OpenMP/allocatable-multiple-vars.f90
@@ -0,0 +1,25 @@
+! Test delayed 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
+
+! CHECK: omp.parallel {
+! CHECK: fir.allocmem
+! CHECK: fir.allocmem
+! CHECK: fir.freemem
+! CHECK: fir.freemem
+! CHECK: omp.terminator
+! CHECK-NEXT: }
``````````
</details>
https://github.com/llvm/llvm-project/pull/93641
More information about the flang-commits
mailing list