File tree 2 files changed +39
-1
lines changed
2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -555,9 +555,16 @@ bool ClauseProcessor::processCopyin() const {
555
555
// synchronize threads and avoid data races on propagation master's thread
556
556
// values of threadprivate variables to local instances of that variables of
557
557
// all other implicit threads.
558
+
559
+ // All copies are inserted at either "insPt" (i.e. immediately before it),
560
+ // or at some earlier point (as determined by "copyHostAssociateVar").
561
+ // Unless the insertion point is given to "copyHostAssociateVar" explicitly,
562
+ // it will not restore the builder's insertion point. Since the copies may be
563
+ // inserted in any order (not following the execution order), make sure the
564
+ // barrier is inserted following all of them.
565
+ firOpBuilder.restoreInsertionPoint (insPt);
558
566
if (hasCopyin)
559
567
firOpBuilder.create <mlir::omp::BarrierOp>(converter.getCurrentLocation ());
560
- firOpBuilder.restoreInsertionPoint (insPt);
561
568
return hasCopyin;
562
569
}
563
570
Original file line number Diff line number Diff line change
1
+ ! RUN: bbc -fopenmp -emit-hlfir -o - %s | FileCheck %s
2
+
3
+ ! CHECK: omp.parallel if(%{{[0-9]+}} : i1) {
4
+ ! CHECK: %[[THP1:[0-9]+]] = omp.threadprivate %{{[0-9]+}}#1
5
+ ! CHECK: %[[DCL1:[0-9]+]]:2 = hlfir.declare %[[THP1]] {uniq_name = "_QFcopyin_scalar_arrayEx1"}
6
+ ! CHECK: %[[LD1:[0-9]+]] = fir.load %{{[0-9]+}}#0
7
+ ! CHECK: hlfir.assign %[[LD1]] to %[[DCL1]]#0 temporary_lhs
8
+ ! CHECK: %[[THP2:[0-9]+]] = omp.threadprivate %{{[0-9]+}}#1
9
+ ! CHECK: %[[SHP2:[0-9]+]] = fir.shape %c{{[0-9]+}}
10
+ ! CHECK: %[[DCL2:[0-9]+]]:2 = hlfir.declare %[[THP2]](%[[SHP2]]) {uniq_name = "_QFcopyin_scalar_arrayEx2"}
11
+ ! CHECK: hlfir.assign %{{[0-9]+}}#0 to %[[DCL2]]#0 temporary_lhs
12
+ ! CHECK: omp.barrier
13
+ ! CHECK: fir.call @_QPsub1(%[[DCL1]]#1, %[[DCL2]]#1)
14
+ ! CHECK: omp.terminator
15
+ ! CHECK: }
16
+
17
+ ! https://github.com/llvm/llvm-project/issues/91205
18
+
19
+ subroutine copyin_scalar_array ()
20
+ integer (kind= 4 ), save :: x1
21
+ integer (kind= 8 ), save :: x2(10 )
22
+ ! $omp threadprivate(x1, x2)
23
+
24
+ ! Have x1 appear before x2 in the AST node for the `parallel construct,
25
+ ! but at the same time have them in a different order in `copyin`.
26
+ ! $omp parallel if (x1 .eq. x2(1)) copyin(x2, x1)
27
+ call sub1(x1, x2)
28
+ ! $omp end parallel
29
+
30
+ end
31
+
You can’t perform that action at this time.
0 commit comments