https://github.com/chandankds created
https://github.com/llvm/llvm-project/pull/71043
None
>From 029b1687e5217e73655442b319a482865587277b Mon Sep 17 00:00:00 2001
From: chandan singh <36783761+chandan...@users.noreply.github.com>
Date: Thu, 2 Nov 2023 11:53:03 +0530
Subject: [PATCH 1/2] [Flang][OpenMP] Port OpenMP threadprivate tests to hlfir
flow
---
.../OpenMP/threadprivate-use-association.f90 | 74 +++
1 file changed, 74 insertions(+)
create mode 100644 flang/test/Lower/OpenMP/threadprivate-use-association.f90
diff --git a/flang/test/Lower/OpenMP/threadprivate-use-association.f90
b/flang/test/Lower/OpenMP/threadprivate-use-association.f90
new file mode 100644
index 000..71d454bb39ce1d1
--- /dev/null
+++ b/flang/test/Lower/OpenMP/threadprivate-use-association.f90
@@ -0,0 +1,74 @@
+! This test checks lowering of OpenMP Threadprivate Directive.
+! Test for threadprivate variable in use association.
+
+!RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s
+
+!CHECK-DAG: fir.global common @blk_(dense<0> : vector<24xi8>) :
!fir.array<24xi8>
+!CHECK-DAG: fir.global @_QMtestEy : f32 {
+
+module test
+ integer :: x
+ real :: y, z(5)
+ common /blk/ x, z
+
+ !$omp threadprivate(y, /blk/)
+
+contains
+ subroutine sub()
+! CHECK-LABEL: @_QMtestPsub
+!CHECK-DAG: [[ADDR0:%.*]] = fir.address_of(@blk_) :
!fir.ref>
+!CHECK-DAG: [[NEWADDR0:%.*]] = omp.threadprivate [[ADDR0]] :
!fir.ref> -> !fir.ref>
+!CHECK-DAG: [[ADDR1:%.*]] = fir.address_of(@_QMtestEy) : !fir.ref
+!CHECK-DAG: [[NEWADDR1:%.*]] = omp.threadprivate [[ADDR1]] : !fir.ref
-> !fir.ref
+
+!$omp parallel
+!CHECK-DAG:[[ADDR2:%.*]] = omp.threadprivate [[ADDR0]] :
!fir.ref> -> !fir.ref>
+!CHECK-DAG:[[ADDR3:%.*]] = omp.threadprivate [[ADDR1]] : !fir.ref ->
!fir.ref
+!CHECK-DAG:[[ADDR4:%.*]] = fir.convert [[ADDR2]] :
(!fir.ref>) -> !fir.ref>
+!CHECK-DAG:[[ADDR5:%.*]] = fir.coordinate_of [[ADDR4]], %{{.*}} :
(!fir.ref>, index) -> !fir.ref
+!CHECK-DAG:[[ADDR6:%.*]] = fir.convert [[ADDR5:%.*]] : (!fir.ref) ->
!fir.ref
+!CHECK-DAG:[[ADDR7:%.*]] = fir.convert [[ADDR2]] :
(!fir.ref>) -> !fir.ref>
+!CHECK-DAG:[[ADDR8:%.*]] = fir.coordinate_of [[ADDR7]], %{{.*}} :
(!fir.ref>, index) -> !fir.ref
+!CHECK-DAG:[[ADDR9:%.*]] = fir.convert [[ADDR8:%.*]] : (!fir.ref) ->
!fir.ref>
+!CHECK-DAG:%{{.*}} = fir.load [[ADDR6]] : !fir.ref
+!CHECK-DAG:%{{.*}} = fir.load [[ADDR3]] : !fir.ref
+!CHECK-DAG:%{{.*}} = fir.embox [[ADDR9]](%{{.*}}) :
(!fir.ref>, !fir.shape<1>) -> !fir.box>
+ print *, x, y, z
+!$omp end parallel
+ end
+end
+
+program main
+ use test
+ integer :: x1
+ real :: z1(5)
+ common /blk/ x1, z1
+
+ !$omp threadprivate(/blk/)
+
+ call sub()
+
+! CHECK-LABEL: @_QQmain()
+!CHECK-DAG: [[ADDR0:%.*]] = fir.address_of(@blk_) :
!fir.ref>
+!CHECK-DAG: [[NEWADDR0:%.*]] = omp.threadprivate [[ADDR0]] :
!fir.ref> -> !fir.ref>
+!CHECK-DAG: [[ADDR1:%.*]] = fir.address_of(@blk_) :
!fir.ref>
+!CHECK-DAG: [[NEWADDR1:%.*]] = omp.threadprivate [[ADDR1]] :
!fir.ref> -> !fir.ref>
+!CHECK-DAG: [[ADDR2:%.*]] = fir.address_of(@_QMtestEy) : !fir.ref
+!CHECK-DAG: [[NEWADDR2:%.*]] = omp.threadprivate [[ADDR2]] : !fir.ref ->
!fir.ref
+
+ !$omp parallel
+!CHECK-DAG:[[ADDR4:%.*]] = omp.threadprivate [[ADDR1]] :
!fir.ref> -> !fir.ref>
+!CHECK-DAG:[[ADDR5:%.*]] = omp.threadprivate [[ADDR2]] : !fir.ref ->
!fir.ref
+!CHECK-DAG:[[ADDR6:%.*]] = fir.convert [[ADDR4]] :
(!fir.ref>) -> !fir.ref>
+!CHECK-DAG:[[ADDR7:%.*]] = fir.coordinate_of [[ADDR6]], %{{.*}} :
(!fir.ref>, index) -> !fir.ref
+!CHECK-DAG:[[ADDR8:%.*]] = fir.convert [[ADDR7:%.*]] : (!fir.ref) ->
!fir.ref
+!CHECK-DAG:[[ADDR9:%.*]] = fir.convert [[ADDR4]] :
(!fir.ref>) -> !fir.ref>
+!CHECK-DAG:[[ADDR10:%.*]] = fir.coordinate_of [[ADDR9]], %{{.*}} :
(!fir.ref>, index) -> !fir.ref
+!CHECK-DAG:[[ADDR11:%.*]] = fir.convert [[ADDR10:%.*]] : (!fir.ref) ->
!fir.ref>
+!CHECK-DAG:%{{.*}} = fir.load [[ADDR8]] : !fir.ref
+!CHECK-DAG:%{{.*}} = fir.load [[ADDR5]] : !fir.ref
+!CHECK-DAG:%{{.*}} = fir.embox [[ADDR11]](%{{.*}}) :
(!fir.ref>, !fir.shape<1>) -> !fir.box>
+print *, x1, y, z1
+ !$omp end parallel
+
+end
>From 85fd277116be1d59dd548b73f136a6f2c748dcba Mon Sep 17 00:00:00 2001
From: chandan singh <36783761+chandan...@users.noreply.github.com>
Date: Thu, 2 Nov 2023 11:57:40 +0530
Subject: [PATCH 2/2] [Flang][OpenMP] Port openmp
threadprivate-use-association.f90 test to HLFIR flow
---
.../OpenMP/threadprivate-use-association.f90 | 56 +++
1 file changed, 32 insertions(+), 24 deletions(-)
diff --git a/flang/test/Lower/OpenMP/threadprivate-use-association.f90
b/flang/test/Lower/OpenMP/threadprivate-use-association.f90
index 71d454bb39ce1d1..d0d461547db2f68 100644
--- a/flang/test/Lower/OpenMP/threadprivate-use-association.f90
+++ b/flang/test/Lower/OpenMP/threadprivate-use-association.f90
@@ -1,7 +1,7 @@
! This test checks lowering of Op