Skip to content

Commit e762cf1

Browse files
committed
[flang][openacc] Allow if_present multiple times on host_data and update
1 parent 8fb6bb3 commit e762cf1

File tree

5 files changed

+17
-15
lines changed

5 files changed

+17
-15
lines changed

flang/test/Lower/OpenACC/acc-host-data.f90

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ subroutine acc_host_data()
2222

2323
! CHECK: %[[DA:.*]] = acc.use_device varPtr(%[[DECLA]]#0 : !fir.ref<!fir.array<10xf32>>) -> !fir.ref<!fir.array<10xf32>> {name = "a"}
2424
! CHECK: acc.host_data dataOperands(%[[DA]] : !fir.ref<!fir.array<10xf32>>) {
25+
! CHECK: } attributes {ifPresent}
26+
27+
!$acc host_data use_device(a) if_present if_present
28+
!$acc end host_data
29+
! CHECK: acc.host_data dataOperands(%{{.*}} : !fir.ref<!fir.array<10xf32>>) {
2530
! CHECK: } attributes {ifPresent}
2631

2732
!$acc host_data use_device(a) if(ifCondition)

flang/test/Lower/OpenACC/acc-update.f90

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ subroutine acc_update
2424
! CHECK: acc.update dataOperands(%[[DEVPTR_A]] : !fir.ref<!fir.array<10x10xf32>>) attributes {ifPresent}{{$}}
2525
! CHECK: acc.update_host accPtr(%[[DEVPTR_A]] : !fir.ref<!fir.array<10x10xf32>>) to varPtr(%[[DECLA]]#0 : !fir.ref<!fir.array<10x10xf32>>) {name = "a", structured = false}
2626

27+
!$acc update host(a) if_present if_present
28+
! CHECK: acc.update dataOperands(%{{.*}} : !fir.ref<!fir.array<10x10xf32>>) attributes {ifPresent}{{$}}
29+
2730
!$acc update self(a)
2831
! CHECK: %[[DEVPTR_A:.*]] = acc.getdeviceptr varPtr(%[[DECLA]]#0 : !fir.ref<!fir.array<10x10xf32>>) -> !fir.ref<!fir.array<10x10xf32>> {dataClause = #acc<data_clause acc_update_self>, name = "a", structured = false}
2932
! CHECK: acc.update dataOperands(%[[DEVPTR_A]] : !fir.ref<!fir.array<10x10xf32>>){{$}}

flang/test/Semantics/OpenACC/acc-host-data.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ program openacc_host_data_validity
2727
!$acc host_data use_device(aa, bb) if_present
2828
!$acc end host_data
2929

30-
!ERROR: At most one IF_PRESENT clause can appear on the HOST_DATA directive
30+
! OK
3131
!$acc host_data use_device(aa, bb) if_present if_present
3232
!$acc end host_data
3333

flang/test/Semantics/OpenACC/acc-update-validity.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ program openacc_update_validity
5858
!ERROR: At most one IF clause can appear on the UPDATE directive
5959
!$acc update device(aa) if(.true.) if(ifCondition)
6060

61-
!ERROR: At most one IF_PRESENT clause can appear on the UPDATE directive
61+
! OK
6262
!$acc update device(bb) if_present if_present
6363

6464
!ERROR: Clause IF is not allowed after clause DEVICE_TYPE on the UPDATE directive

llvm/include/llvm/Frontend/OpenACC/ACC.td

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -487,15 +487,11 @@ def ACC_Shutdown : Directive<"shutdown"> {
487487

488488
// 2.14.4
489489
def ACC_Update : Directive<"update"> {
490-
let allowedClauses = [
491-
VersionedClause<ACCC_DeviceType>,
492-
VersionedClause<ACCC_Wait>
493-
];
494-
let allowedOnceClauses = [
495-
VersionedClause<ACCC_Async>,
496-
VersionedClause<ACCC_If>,
497-
VersionedClause<ACCC_IfPresent>
498-
];
490+
let allowedClauses = [VersionedClause<ACCC_DeviceType>,
491+
VersionedClause<ACCC_IfPresent>,
492+
VersionedClause<ACCC_Wait>];
493+
let allowedOnceClauses = [VersionedClause<ACCC_Async>,
494+
VersionedClause<ACCC_If>];
499495
let requiredClauses = [
500496
VersionedClause<ACCC_Device>,
501497
VersionedClause<ACCC_Host>,
@@ -554,10 +550,8 @@ def ACC_ExitData : Directive<"exit data"> {
554550

555551
// 2.8
556552
def ACC_HostData : Directive<"host_data"> {
557-
let allowedOnceClauses = [
558-
VersionedClause<ACCC_If>,
559-
VersionedClause<ACCC_IfPresent>
560-
];
553+
let allowedClauses = [VersionedClause<ACCC_IfPresent>];
554+
let allowedOnceClauses = [VersionedClause<ACCC_If>];
561555
let requiredClauses = [
562556
VersionedClause<ACCC_UseDevice>
563557
];

0 commit comments

Comments
 (0)