-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[flang][hlfir][openacc] Updated LIT tests checks. #66099
Conversation
This patch updates the OpenACC LIT tests to invoke HLFIR lowering in addition to FIR lowering. The tests checks were updated accordingly.
@llvm/pr-subscribers-openacc ChangesThis patch updates the OpenACC LIT tests to invoke HLFIR lowering -- Patch is 344.65 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/66099.diff 25 Files Affected:
diff --git a/flang/test/Lower/OpenACC/acc-data-operands.f90 b/flang/test/Lower/OpenACC/acc-data-operands.f90 index bedb1a48ea58912..3ec78c4b781d7a5 100644 --- a/flang/test/Lower/OpenACC/acc-data-operands.f90 +++ b/flang/test/Lower/OpenACC/acc-data-operands.f90 @@ -1,6 +1,7 @@ ! This test checks lowering of complex OpenACC data operands. -! RUN: bbc -fopenacc -emit-fir %s -o - | FileCheck %s +! RUN: bbc -fopenacc -emit-fir %s -o - | FileCheck %s --check-prefixes=CHECK,FIR +! RUN: bbc -fopenacc -emit-hlfir %s -o - | FileCheck %s --check-prefixes=CHECK,HLFIR module acc_data_operand @@ -20,21 +21,25 @@ subroutine acc_operand_array_section() ! CHECK-LABEL: func.func @_QMacc_data_operandPacc_operand_array_section ! CHECK: %[[ARR:.*]] = fir.alloca !fir.array<100xf32> +! HLFIR: %[[DECL:.*]]:2 = hlfir.declare %[[ARR]] ! CHECK: %[[ONE:.*]] = arith.constant 1 : index ! CHECK: %[[LB:.*]] = arith.constant 0 : index ! CHECK: %[[UB:.*]] = arith.constant 49 : index ! CHECK: %[[BOUND_1_50:.*]] = acc.bounds lowerbound(%[[LB]] : index) upperbound(%[[UB]] : index) stride(%[[ONE]] : index) startIdx(%[[ONE]] : index) -! CHECK: %[[COPYIN:.*]] = acc.copyin varPtr(%[[ARR]] : !fir.ref>) bounds(%[[BOUND_1_50]]) -> !fir.ref> {name = "a(1:50)"} +! FIR: %[[COPYIN:.*]] = acc.copyin varPtr(%[[ARR]] : !fir.ref>) bounds(%[[BOUND_1_50]]) -> !fir.ref> {name = "a(1:50)"} +! HLFIR: %[[COPYIN:.*]] = acc.copyin varPtr(%[[DECL]]#1 : !fir.ref>) bounds(%[[BOUND_1_50]]) -> !fir.ref> {name = "a(1:50)"} ! CHECK: %[[ONE:.*]] = arith.constant 1 : index ! CHECK: %[[LB:.*]] = arith.constant 50 : index ! CHECK: %[[UB:.*]] = arith.constant 99 : index ! CHECK: %[[BOUND_51_100:.*]] = acc.bounds lowerbound(%[[LB]] : index) upperbound(%[[UB]] : index) stride(%[[ONE]] : index) startIdx(%[[ONE]] : index) -! CHECK: %[[COPYOUT_CREATE:.*]] = acc.create varPtr(%[[ARR]] : !fir.ref>) bounds(%[[BOUND_51_100]]) -> !fir.ref> {dataClause = #acc, name = "a(51:100)"} +! FIR: %[[COPYOUT_CREATE:.*]] = acc.create varPtr(%[[ARR]] : !fir.ref>) bounds(%[[BOUND_51_100]]) -> !fir.ref> {dataClause = #acc, name = "a(51:100)"} +! HLFIR: %[[COPYOUT_CREATE:.*]] = acc.create varPtr(%[[DECL]]#1 : !fir.ref>) bounds(%[[BOUND_51_100]]) -> !fir.ref> {dataClause = #acc, name = "a(51:100)"} ! CHECK: acc.data dataOperands(%[[COPYIN]], %[[COPYOUT_CREATE]] : !fir.ref>, !fir.ref>) { ! CHECK: acc.terminator ! CHECK: } -! CHECK: acc.copyout accPtr(%[[COPYOUT_CREATE]] : !fir.ref>) bounds(%[[BOUND_51_100]]) to varPtr(%[[ARR]] : !fir.ref>) {name = "a(51:100)"} - +! FIR: acc.copyout accPtr(%[[COPYOUT_CREATE]] : !fir.ref>) bounds(%[[BOUND_51_100]]) to varPtr(%[[ARR]] : !fir.ref>) {name = "a(51:100)"} +! HLFIR: acc.copyout accPtr(%[[COPYOUT_CREATE]] : !fir.ref>) bounds(%[[BOUND_51_100]]) to varPtr(%[[DECL]]#1 : !fir.ref>) {name = "a(51:100)"} + ! Testing array sections of a derived-type component subroutine acc_operand_array_section_component() @@ -46,8 +51,10 @@ subroutine acc_operand_array_section_component() ! CHECK-LABEL: func.func @_QMacc_data_operandPacc_operand_array_section_component() { ! CHECK: %[[W:.*]] = fir.alloca !fir.type<_QMacc_data_operandTwrapper{data:!fir.array<100xf32>}> {bindc_name = "w", uniq_name = "_QMacc_data_operandFacc_operand_array_section_componentEw"} -! CHECK: %[[FIELD_DATA:.*]] = fir.field_index data, !fir.type<_QMacc_data_operandTwrapper{data:!fir.array<100xf32>}> -! CHECK: %[[COORD_DATA:.*]] = fir.coordinate_of %[[W]], %[[FIELD_DATA]] : (!fir.ref}>>, !fir.field) -> !fir.ref> +! HLFIR: %[[DECLW:.*]]:2 = hlfir.declare %[[W]] +! FIR: %[[FIELD_DATA:.*]] = fir.field_index data, !fir.type<_QMacc_data_operandTwrapper{data:!fir.array<100xf32>}> +! FIR: %[[COORD_DATA:.*]] = fir.coordinate_of %[[W]], %[[FIELD_DATA]] : (!fir.ref}>>, !fir.field) -> !fir.ref> +! HLFIR: %[[COORD_DATA:.*]] = hlfir.designate %[[DECLW]]#0{"data"} shape %{{.*}} : (!fir.ref}>>, !fir.shape<1>) -> !fir.ref> ! CHECK: %[[ONE:.*]] = arith.constant 1 : index ! CHECK: %[[LB:.*]] = arith.constant 0 : index ! CHECK: %[[UB:.*]] = arith.constant 19 : index @@ -68,9 +75,12 @@ subroutine acc_operand_derived_type_component() ! CHECK-LABEL: func.func @_QMacc_data_operandPacc_operand_derived_type_component() { ! CHECK: %[[W:.*]] = fir.alloca !fir.type<_QMacc_data_operandTwrapper{data:!fir.array<100xf32>}> {bindc_name = "w", uniq_name = "_QMacc_data_operandFacc_operand_derived_type_componentEw"} -! CHECK: %[[FIELD_DATA:.*]] = fir.field_index data, !fir.type<_QMacc_data_operandTwrapper{data:!fir.array<100xf32>}> -! CHECK: %[[COORD_DATA:.*]] = fir.coordinate_of %[[W]], %[[FIELD_DATA]] : (!fir.ref}>>, !fir.field) -> !fir.ref}> +! FIR: %[[COORD_DATA:.*]] = fir.coordinate_of %[[W]], %[[FIELD_DATA]] : (!fir.ref}>>, !fir.field) -> !fir.ref}>>, !fir.shape<1>) -> !fir.ref> +! FIR: %[[EXT:.*]] = arith.constant 100 : index ! CHECK: %[[ONE:.*]] = arith.constant 1 : index ! CHECK: %[[LB:.*]] = arith.constant 0 : index ! CHECK: %[[UB:.*]] = arith.subi %[[EXT]], %[[ONE]] : index @@ -92,17 +102,22 @@ subroutine acc_operand_array_derived_type_component() ! CHECK-LABEL: func.func @_QMacc_data_operandPacc_operand_array_derived_type_component() { ! CHECK: %[[W:.*]] = fir.alloca !fir.array<10x!fir.type<_QMacc_data_operandTwrapper{data:!fir.array<100xf32>}>> {bindc_name = "w", uniq_name = "_QMacc_data_operandFacc_operand_array_derived_type_componentEw"} -! CHECK: %[[C1:.*]] = arith.constant 1 : i64 -! CHECK: %[[SUB:.*]] = arith.constant 1 : i64 -! CHECK: %[[IDX:.*]] = arith.subi %[[C1]], %[[SUB]] : i64 -! CHECK: %[[W_1:.*]] = fir.coordinate_of %[[W]], %[[IDX]] : (!fir.ref}>>>, i64) -> !fir.ref}>> -! CHECK: %[[FIELD_DATA:.*]] = fir.field_index data, !fir.type<_QMacc_data_operandTwrapper{data:!fir.array<100xf32>}> -! CHECK: %[[COORD_W1_DATA:.*]] = fir.coordinate_of %[[W_1]], %[[FIELD_DATA]] : (!fir.ref}>>, !fir.field) -> !fir.ref> -! CHECK: %[[EXT:.*]] = arith.constant 100 : index +! HLFIR: %[[DECLW:.*]]:2 = hlfir.declare %[[W]] +! FIR: %[[C1:.*]] = arith.constant 1 : i64 +! FIR: %[[SUB:.*]] = arith.constant 1 : i64 +! FIR: %[[IDX:.*]] = arith.subi %[[C1]], %[[SUB]] : i64 +! FIR: %[[W_1:.*]] = fir.coordinate_of %[[W]], %[[IDX]] : (!fir.ref}>>>, i64) -> !fir.ref}>> +! HLFIR: %[[C1:.*]] = arith.constant 1 : index +! HLFIR: %[[W_1:.*]] = hlfir.designate %[[DECLW]]#0 (%[[C1]]) : (!fir.ref}>>>, index) -> !fir.ref}>> +! FIR: %[[FIELD_DATA:.*]] = fir.field_index data, !fir.type<_QMacc_data_operandTwrapper{data:!fir.array<100xf32>}> +! FIR: %[[COORD_W1_DATA:.*]] = fir.coordinate_of %[[W_1]], %[[FIELD_DATA]] : (!fir.ref}>>, !fir.field) -> !fir.ref> +! HLFIR: %[[EXT:.*]] = arith.constant 100 : index +! HLFIR: %[[COORD_W1_DATA:.*]] = hlfir.designate %[[W_1]]{"data"} shape %{{.*}} : (!fir.ref}>>, !fir.shape<1>) -> !fir.ref> +! FIR: %[[EXT:.*]] = arith.constant 100 : index ! CHECK: %[[ONE:.*]] = arith.constant 1 : index ! CHECK: %[[LB:.*]] = arith.constant 0 : index ! CHECK: %[[UB:.*]] = arith.subi %[[EXT]], %[[ONE]] : index -! CHECK: %[[BOUND:.*]] = acc.bounds lowerbound(%[[LB]] : index) upperbound(%[[UB]] : index) extent(%[[EXT]] : index) stride(%[[ONE]] : index) startIdx(%[[ONE]] : index) +! CHECK: %[[BOUND:.*]] = acc.bounds lowerbound(%[[LB]] : index) upperbound(%[[UB]] : index) extent(%[[EXT]] : index) stride(%[[ONE]] : index) startIdx(%[[ONE]] : index) ! CHECK: %[[COPY_COPYIN:.*]] = acc.copyin varPtr(%[[COORD_W1_DATA]] : !fir.ref>) bounds(%[[BOUND]]) -> !fir.ref> {dataClause = #acc, name = "w(1_8)%data"} ! CHECK: acc.data dataOperands(%[[COPY_COPYIN]] : !fir.ref>) { ! CHECK: acc.terminator @@ -123,8 +138,11 @@ subroutine acc_operand_array_section_allocatable() ! CHECK-LABEL: func.func @_QMacc_data_operandPacc_operand_array_section_allocatable() { ! CHECK: %[[A:.*]] = fir.alloca !fir.box>> {bindc_name = "a", uniq_name = "_QMacc_data_operandFacc_operand_array_section_allocatableEa"} -! CHECK: %[[LOAD_BOX_A_0:.*]] = fir.load %[[A]] : !fir.ref>>> -! CHECK: %[[LOAD_BOX_A_1:.*]] = fir.load %[[A]] : !fir.ref>>> +! HLFIR: %[[DECLA:.*]]:2 = hlfir.declare %[[A]] {fortran_attrs = #fir.var_attrs +! FIR: %[[LOAD_BOX_A_0:.*]] = fir.load %[[A]] : !fir.ref>>> +! FIR: %[[LOAD_BOX_A_1:.*]] = fir.load %[[A]] : !fir.ref>>> +! HLFIR: %[[LOAD_BOX_A_0:.*]] = fir.load %[[DECLA]]#1 : !fir.ref>>> +! HLFIR: %[[LOAD_BOX_A_1:.*]] = fir.load %[[DECLA]]#1 : !fir.ref>>> ! CHECK: %[[C0:.*]] = arith.constant 0 : index ! CHECK: %[[DIMS0_0:.*]]:3 = fir.box_dims %[[LOAD_BOX_A_1]], %[[C0]] : (!fir.box>>, index) -> (index, index, index) ! CHECK: %[[C0:.*]] = arith.constant 0 : index @@ -136,8 +154,10 @@ subroutine acc_operand_array_section_allocatable() ! CHECK: %[[BOUND:.*]] = acc.bounds lowerbound(%[[LB]] : index) upperbound(%[[UB]] : index) stride(%[[DIMS0_1]]#2 : index) startIdx(%[[DIMS0_0]]#0 : index) {strideInBytes = true} ! CHECK: %[[BOX_ADDR:.*]] = fir.box_addr %[[LOAD_BOX_A_0]] : (!fir.box>>) -> !fir.heap> ! CHECK: %[[COPYIN:.*]] = acc.copyin varPtr(%[[BOX_ADDR]] : !fir.heap>) bounds(%[[BOUND]]) -> !fir.heap> {name = "a(1:50)"} -! CHECK: %[[LOAD_BOX_A_0:.*]] = fir.load %[[A]] : !fir.ref>>> -! CHECK: %[[LOAD_BOX_A_1:.*]] = fir.load %[[A]] : !fir.ref>>> +! FIR: %[[LOAD_BOX_A_0:.*]] = fir.load %[[A]] : !fir.ref>>> +! FIR: %[[LOAD_BOX_A_1:.*]] = fir.load %[[A]] : !fir.ref>>> +! HLFIR: %[[LOAD_BOX_A_0:.*]] = fir.load %[[DECLA]]#1 : !fir.ref>>> +! HLFIR: %[[LOAD_BOX_A_1:.*]] = fir.load %[[DECLA]]#1 : !fir.ref>>> ! CHECK: %[[C0:.*]] = arith.constant 0 : index ! CHECK: %[[DIMS0_0:.*]]:3 = fir.box_dims %[[LOAD_BOX_A_1]], %[[C0]] : (!fir.box>>, index) -> (index, index, index) ! CHECK: %[[C0:.*]] = arith.constant 0 : index @@ -168,8 +188,11 @@ subroutine acc_operand_array_section_pointer() ! CHECK-LABEL: func.func @_QMacc_data_operandPacc_operand_array_section_pointer() { ! CHECK: %[[P:.*]] = fir.alloca !fir.box>> {bindc_name = "p", uniq_name = "_QMacc_data_operandFacc_operand_array_section_pointerEp"} -! CHECK: %[[LOAD_BOX_P_0:.*]] = fir.load %[[P]] : !fir.ref>>> -! CHECK: %[[LOAD_BOX_P_1:.*]] = fir.load %[[P]] : !fir.ref>>> +! HLFIR: %[[DECLP:.*]]:2 = hlfir.declare %[[P]] {fortran_attrs = #fir.var_attrs +! FIR: %[[LOAD_BOX_P_0:.*]] = fir.load %[[P]] : !fir.ref>>> +! FIR: %[[LOAD_BOX_P_1:.*]] = fir.load %[[P]] : !fir.ref>>> +! HLFIR: %[[LOAD_BOX_P_0:.*]] = fir.load %[[DECLP]]#1 : !fir.ref>>> +! HLFIR: %[[LOAD_BOX_P_1:.*]] = fir.load %[[DECLP]]#1 : !fir.ref>>> ! CHECK: %[[C0:.*]] = arith.constant 0 : index ! CHECK: %[[DIMS0_0:.*]]:3 = fir.box_dims %[[LOAD_BOX_P_1]], %[[C0:.*]] : (!fir.box>>, index) -> (index, index, index) ! CHECK: %[[C0:.*]] = arith.constant 0 : index diff --git a/flang/test/Lower/OpenACC/acc-data.f90 b/flang/test/Lower/OpenACC/acc-data.f90 index 5226474d012c13c..c749f1948bbbe1f 100644 --- a/flang/test/Lower/OpenACC/acc-data.f90 +++ b/flang/test/Lower/OpenACC/acc-data.f90 @@ -1,6 +1,7 @@ ! This test checks lowering of OpenACC data directive. -! RUN: bbc -fopenacc -emit-fir %s -o - | FileCheck %s +! RUN: bbc -fopenacc -emit-fir %s -o - | FileCheck %s --check-prefixes=CHECK,FIR +! RUN: bbc -fopenacc -emit-hlfir %s -o - | FileCheck %s --check-prefixes=CHECK,HLFIR subroutine acc_data real, dimension(10, 10) :: a, b, c @@ -8,64 +9,88 @@ subroutine acc_data logical :: ifCondition = .TRUE. ! CHECK: %[[A:.*]] = fir.alloca !fir.array<10x10xf32> {{{.*}}uniq_name = "{{.*}}Ea"} +! HLFIR: %[[DECLA:.*]]:2 = hlfir.declare %[[A]] ! CHECK: %[[B:.*]] = fir.alloca !fir.array<10x10xf32> {{{.*}}uniq_name = "{{.*}}Eb"} +! HLFIR: %[[DECLB:.*]]:2 = hlfir.declare %[[B]] ! CHECK: %[[C:.*]] = fir.alloca !fir.array<10x10xf32> {{{.*}}uniq_name = "{{.*}}Ec"} +! HLFIR: %[[DECLC:.*]]:2 = hlfir.declare %[[C]] ! CHECK: %[[D:.*]] = fir.alloca !fir.box> {bindc_name = "d", uniq_name = "{{.*}}Ed"} +! HLFIR: %[[DECLD:.*]]:2 = hlfir.declare %[[D]] ! CHECK: %[[E:.*]] = fir.alloca !fir.box> {bindc_name = "e", uniq_name = "{{.*}}Ee"} +! HLFIR: %[[DECLE:.*]]:2 = hlfir.declare %[[E]] !$acc data if(.TRUE.) copy(a) !$acc end data ! CHECK: %[[IF1:.*]] = arith.constant true -! CHECK: %[[COPYIN:.*]] = acc.copyin varPtr(%[[A]] : !fir.ref>) bounds(%{{.*}}, %{{.*}}) -> !fir.ref> {dataClause = #acc, name = "a"} +! FIR: %[[COPYIN:.*]] = acc.copyin varPtr(%[[A]] : !fir.ref>) bounds(%{{.*}}, %{{.*}}) -> !fir.ref> {dataClause = #acc, name = "a"} +! HLFIR: %[[COPYIN:.*]] = acc.copyin varPtr(%[[DECLA]]#1 : !fir.ref>) bounds(%{{.*}}, %{{.*}}) -> !fir.ref> {dataClause = #acc, name = "a"} ! CHECK: acc.data if(%[[IF1]]) dataOperands(%[[COPYIN]] : !fir.ref>) { ! CHECK: acc.terminator ! CHECK-NEXT: }{{$}} -! CHECK: acc.copyout accPtr(%[[COPYIN]] : !fir.ref>) bounds(%{{.*}}, %{{.*}}) to varPtr(%[[A]] : !fir.ref>) {dataClause = #acc, name = "a"} +! FIR: acc.copyout accPtr(%[[COPYIN]] : !fir.ref>) bounds(%{{.*}}, %{{.*}}) to varPtr(%[[A]] : !fir.ref>) {dataClause = #acc, name = "a"} +! HLFIR: acc.copyout accPtr(%[[COPYIN]] : !fir.ref>) bounds(%{{.*}}, %{{.*}}) to varPtr(%[[DECLA]]#1 : !fir.ref>) {dataClause = #acc, name = "a"} !$acc data copy(a) if(ifCondition) !$acc end data -! CHECK: %[[COPYIN:.*]] = acc.copyin varPtr(%[[A]] : !fir.ref>) bounds(%{{.*}}, %{{.*}}) -> !fir.ref> {dataClause = #acc, name = "a"} +! FIR: %[[COPYIN:.*]] = acc.copyin varPtr(%[[A]] : !fir.ref>) bounds(%{{.*}}, %{{.*}}) -> !fir.ref> {dataClause = #acc, name = "a"} +! HLFIR: %[[COPYIN:.*]] = acc.copyin varPtr(%[[DECLA]]#1 : !fir.ref>) bounds(%{{.*}}, %{{.*}}) -> !fir.ref> {dataClause = #acc, name = "a"} ! CHECK: %[[IFCOND:.*]] = fir.load %{{.*}} : !fir.ref> ! CHECK: %[[IF2:.*]] = fir.convert %[[IFCOND]] : (!fir.logical<4>) -> i1 ! CHECK: acc.data if(%[[IF2]]) dataOperands(%[[COPYIN]] : !fir.ref>) { ! CHECK: acc.terminator ! CHECK-NEXT: }{{$}} -! CHECK: acc.copyout accPtr(%[[COPYIN]] : !fir.ref>) bounds(%{{.*}}, %{{.*}}) to varPtr(%[[A]] : !fir.ref>) {dataClause = #acc, name = "a"} +! FIR: acc.copyout accPtr(%[[COPYIN]] : !fir.ref>) bounds(%{{.*}}, %{{.*}}) to varPtr(%[[A]] : !fir.ref>) {dataClause = #acc, name = "a"} +! HLFIR: acc.copyout accPtr(%[[COPYIN]] : !fir.ref>) bounds(%{{.*}}, %{{.*}}) to varPtr(%[[DECLA]]#1 : !fir.ref>) {dataClause = #acc, name = "a"} !$acc data copy(a, b, c) !$acc end data -! CHECK: %[[COPYIN_A:.*]] = acc.copyin varPtr(%[[A]] : !fir.ref>) bounds(%{{.*}}, %{{.*}}) -> !fir.ref> {dataClause = #acc, name = "a"} -! CHECK: %[[COPYIN_B:.*]] = acc.copyin varPtr(%[[B]] : !fir.ref>) bounds(%{{.*}}, %{{.*}}) -> !fir.ref> {dataClause = #acc, name = "b"} -! CHECK: %[[COPYIN_C:.*]] = acc.copyin varPtr(%[[C]] : !fir.ref>) bounds(%{{.*}}, %{{.*}}) -> !fir.ref> {dataClause = #acc, name = "c"} +! FIR: %[[COPYIN_A:.*]] = acc.copyin varPtr(%[[A]] : !fir.ref>) bounds(%{{.*}}, %{{.*}}) -> !fir.ref... |
@llvm/pr-subscribers-flang-fir-hlfir ChangesThis patch updates the OpenACC LIT tests to invoke HLFIR lowering -- Patch is 344.65 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/66099.diff 25 Files Affected:
diff --git a/flang/test/Lower/OpenACC/acc-data-operands.f90 b/flang/test/Lower/OpenACC/acc-data-operands.f90 index bedb1a48ea58912..3ec78c4b781d7a5 100644 --- a/flang/test/Lower/OpenACC/acc-data-operands.f90 +++ b/flang/test/Lower/OpenACC/acc-data-operands.f90 @@ -1,6 +1,7 @@ ! This test checks lowering of complex OpenACC data operands. -! RUN: bbc -fopenacc -emit-fir %s -o - | FileCheck %s +! RUN: bbc -fopenacc -emit-fir %s -o - | FileCheck %s --check-prefixes=CHECK,FIR +! RUN: bbc -fopenacc -emit-hlfir %s -o - | FileCheck %s --check-prefixes=CHECK,HLFIR module acc_data_operand @@ -20,21 +21,25 @@ subroutine acc_operand_array_section() ! CHECK-LABEL: func.func @_QMacc_data_operandPacc_operand_array_section ! CHECK: %[[ARR:.*]] = fir.alloca !fir.array<100xf32> +! HLFIR: %[[DECL:.*]]:2 = hlfir.declare %[[ARR]] ! CHECK: %[[ONE:.*]] = arith.constant 1 : index ! CHECK: %[[LB:.*]] = arith.constant 0 : index ! CHECK: %[[UB:.*]] = arith.constant 49 : index ! CHECK: %[[BOUND_1_50:.*]] = acc.bounds lowerbound(%[[LB]] : index) upperbound(%[[UB]] : index) stride(%[[ONE]] : index) startIdx(%[[ONE]] : index) -! CHECK: %[[COPYIN:.*]] = acc.copyin varPtr(%[[ARR]] : !fir.ref>) bounds(%[[BOUND_1_50]]) -> !fir.ref> {name = "a(1:50)"} +! FIR: %[[COPYIN:.*]] = acc.copyin varPtr(%[[ARR]] : !fir.ref>) bounds(%[[BOUND_1_50]]) -> !fir.ref> {name = "a(1:50)"} +! HLFIR: %[[COPYIN:.*]] = acc.copyin varPtr(%[[DECL]]#1 : !fir.ref>) bounds(%[[BOUND_1_50]]) -> !fir.ref> {name = "a(1:50)"} ! CHECK: %[[ONE:.*]] = arith.constant 1 : index ! CHECK: %[[LB:.*]] = arith.constant 50 : index ! CHECK: %[[UB:.*]] = arith.constant 99 : index ! CHECK: %[[BOUND_51_100:.*]] = acc.bounds lowerbound(%[[LB]] : index) upperbound(%[[UB]] : index) stride(%[[ONE]] : index) startIdx(%[[ONE]] : index) -! CHECK: %[[COPYOUT_CREATE:.*]] = acc.create varPtr(%[[ARR]] : !fir.ref>) bounds(%[[BOUND_51_100]]) -> !fir.ref> {dataClause = #acc, name = "a(51:100)"} +! FIR: %[[COPYOUT_CREATE:.*]] = acc.create varPtr(%[[ARR]] : !fir.ref>) bounds(%[[BOUND_51_100]]) -> !fir.ref> {dataClause = #acc, name = "a(51:100)"} +! HLFIR: %[[COPYOUT_CREATE:.*]] = acc.create varPtr(%[[DECL]]#1 : !fir.ref>) bounds(%[[BOUND_51_100]]) -> !fir.ref> {dataClause = #acc, name = "a(51:100)"} ! CHECK: acc.data dataOperands(%[[COPYIN]], %[[COPYOUT_CREATE]] : !fir.ref>, !fir.ref>) { ! CHECK: acc.terminator ! CHECK: } -! CHECK: acc.copyout accPtr(%[[COPYOUT_CREATE]] : !fir.ref>) bounds(%[[BOUND_51_100]]) to varPtr(%[[ARR]] : !fir.ref>) {name = "a(51:100)"} - +! FIR: acc.copyout accPtr(%[[COPYOUT_CREATE]] : !fir.ref>) bounds(%[[BOUND_51_100]]) to varPtr(%[[ARR]] : !fir.ref>) {name = "a(51:100)"} +! HLFIR: acc.copyout accPtr(%[[COPYOUT_CREATE]] : !fir.ref>) bounds(%[[BOUND_51_100]]) to varPtr(%[[DECL]]#1 : !fir.ref>) {name = "a(51:100)"} + ! Testing array sections of a derived-type component subroutine acc_operand_array_section_component() @@ -46,8 +51,10 @@ subroutine acc_operand_array_section_component() ! CHECK-LABEL: func.func @_QMacc_data_operandPacc_operand_array_section_component() { ! CHECK: %[[W:.*]] = fir.alloca !fir.type<_QMacc_data_operandTwrapper{data:!fir.array<100xf32>}> {bindc_name = "w", uniq_name = "_QMacc_data_operandFacc_operand_array_section_componentEw"} -! CHECK: %[[FIELD_DATA:.*]] = fir.field_index data, !fir.type<_QMacc_data_operandTwrapper{data:!fir.array<100xf32>}> -! CHECK: %[[COORD_DATA:.*]] = fir.coordinate_of %[[W]], %[[FIELD_DATA]] : (!fir.ref}>>, !fir.field) -> !fir.ref> +! HLFIR: %[[DECLW:.*]]:2 = hlfir.declare %[[W]] +! FIR: %[[FIELD_DATA:.*]] = fir.field_index data, !fir.type<_QMacc_data_operandTwrapper{data:!fir.array<100xf32>}> +! FIR: %[[COORD_DATA:.*]] = fir.coordinate_of %[[W]], %[[FIELD_DATA]] : (!fir.ref}>>, !fir.field) -> !fir.ref> +! HLFIR: %[[COORD_DATA:.*]] = hlfir.designate %[[DECLW]]#0{"data"} shape %{{.*}} : (!fir.ref}>>, !fir.shape<1>) -> !fir.ref> ! CHECK: %[[ONE:.*]] = arith.constant 1 : index ! CHECK: %[[LB:.*]] = arith.constant 0 : index ! CHECK: %[[UB:.*]] = arith.constant 19 : index @@ -68,9 +75,12 @@ subroutine acc_operand_derived_type_component() ! CHECK-LABEL: func.func @_QMacc_data_operandPacc_operand_derived_type_component() { ! CHECK: %[[W:.*]] = fir.alloca !fir.type<_QMacc_data_operandTwrapper{data:!fir.array<100xf32>}> {bindc_name = "w", uniq_name = "_QMacc_data_operandFacc_operand_derived_type_componentEw"} -! CHECK: %[[FIELD_DATA:.*]] = fir.field_index data, !fir.type<_QMacc_data_operandTwrapper{data:!fir.array<100xf32>}> -! CHECK: %[[COORD_DATA:.*]] = fir.coordinate_of %[[W]], %[[FIELD_DATA]] : (!fir.ref}>>, !fir.field) -> !fir.ref}> +! FIR: %[[COORD_DATA:.*]] = fir.coordinate_of %[[W]], %[[FIELD_DATA]] : (!fir.ref}>>, !fir.field) -> !fir.ref}>>, !fir.shape<1>) -> !fir.ref> +! FIR: %[[EXT:.*]] = arith.constant 100 : index ! CHECK: %[[ONE:.*]] = arith.constant 1 : index ! CHECK: %[[LB:.*]] = arith.constant 0 : index ! CHECK: %[[UB:.*]] = arith.subi %[[EXT]], %[[ONE]] : index @@ -92,17 +102,22 @@ subroutine acc_operand_array_derived_type_component() ! CHECK-LABEL: func.func @_QMacc_data_operandPacc_operand_array_derived_type_component() { ! CHECK: %[[W:.*]] = fir.alloca !fir.array<10x!fir.type<_QMacc_data_operandTwrapper{data:!fir.array<100xf32>}>> {bindc_name = "w", uniq_name = "_QMacc_data_operandFacc_operand_array_derived_type_componentEw"} -! CHECK: %[[C1:.*]] = arith.constant 1 : i64 -! CHECK: %[[SUB:.*]] = arith.constant 1 : i64 -! CHECK: %[[IDX:.*]] = arith.subi %[[C1]], %[[SUB]] : i64 -! CHECK: %[[W_1:.*]] = fir.coordinate_of %[[W]], %[[IDX]] : (!fir.ref}>>>, i64) -> !fir.ref}>> -! CHECK: %[[FIELD_DATA:.*]] = fir.field_index data, !fir.type<_QMacc_data_operandTwrapper{data:!fir.array<100xf32>}> -! CHECK: %[[COORD_W1_DATA:.*]] = fir.coordinate_of %[[W_1]], %[[FIELD_DATA]] : (!fir.ref}>>, !fir.field) -> !fir.ref> -! CHECK: %[[EXT:.*]] = arith.constant 100 : index +! HLFIR: %[[DECLW:.*]]:2 = hlfir.declare %[[W]] +! FIR: %[[C1:.*]] = arith.constant 1 : i64 +! FIR: %[[SUB:.*]] = arith.constant 1 : i64 +! FIR: %[[IDX:.*]] = arith.subi %[[C1]], %[[SUB]] : i64 +! FIR: %[[W_1:.*]] = fir.coordinate_of %[[W]], %[[IDX]] : (!fir.ref}>>>, i64) -> !fir.ref}>> +! HLFIR: %[[C1:.*]] = arith.constant 1 : index +! HLFIR: %[[W_1:.*]] = hlfir.designate %[[DECLW]]#0 (%[[C1]]) : (!fir.ref}>>>, index) -> !fir.ref}>> +! FIR: %[[FIELD_DATA:.*]] = fir.field_index data, !fir.type<_QMacc_data_operandTwrapper{data:!fir.array<100xf32>}> +! FIR: %[[COORD_W1_DATA:.*]] = fir.coordinate_of %[[W_1]], %[[FIELD_DATA]] : (!fir.ref}>>, !fir.field) -> !fir.ref> +! HLFIR: %[[EXT:.*]] = arith.constant 100 : index +! HLFIR: %[[COORD_W1_DATA:.*]] = hlfir.designate %[[W_1]]{"data"} shape %{{.*}} : (!fir.ref}>>, !fir.shape<1>) -> !fir.ref> +! FIR: %[[EXT:.*]] = arith.constant 100 : index ! CHECK: %[[ONE:.*]] = arith.constant 1 : index ! CHECK: %[[LB:.*]] = arith.constant 0 : index ! CHECK: %[[UB:.*]] = arith.subi %[[EXT]], %[[ONE]] : index -! CHECK: %[[BOUND:.*]] = acc.bounds lowerbound(%[[LB]] : index) upperbound(%[[UB]] : index) extent(%[[EXT]] : index) stride(%[[ONE]] : index) startIdx(%[[ONE]] : index) +! CHECK: %[[BOUND:.*]] = acc.bounds lowerbound(%[[LB]] : index) upperbound(%[[UB]] : index) extent(%[[EXT]] : index) stride(%[[ONE]] : index) startIdx(%[[ONE]] : index) ! CHECK: %[[COPY_COPYIN:.*]] = acc.copyin varPtr(%[[COORD_W1_DATA]] : !fir.ref>) bounds(%[[BOUND]]) -> !fir.ref> {dataClause = #acc, name = "w(1_8)%data"} ! CHECK: acc.data dataOperands(%[[COPY_COPYIN]] : !fir.ref>) { ! CHECK: acc.terminator @@ -123,8 +138,11 @@ subroutine acc_operand_array_section_allocatable() ! CHECK-LABEL: func.func @_QMacc_data_operandPacc_operand_array_section_allocatable() { ! CHECK: %[[A:.*]] = fir.alloca !fir.box>> {bindc_name = "a", uniq_name = "_QMacc_data_operandFacc_operand_array_section_allocatableEa"} -! CHECK: %[[LOAD_BOX_A_0:.*]] = fir.load %[[A]] : !fir.ref>>> -! CHECK: %[[LOAD_BOX_A_1:.*]] = fir.load %[[A]] : !fir.ref>>> +! HLFIR: %[[DECLA:.*]]:2 = hlfir.declare %[[A]] {fortran_attrs = #fir.var_attrs +! FIR: %[[LOAD_BOX_A_0:.*]] = fir.load %[[A]] : !fir.ref>>> +! FIR: %[[LOAD_BOX_A_1:.*]] = fir.load %[[A]] : !fir.ref>>> +! HLFIR: %[[LOAD_BOX_A_0:.*]] = fir.load %[[DECLA]]#1 : !fir.ref>>> +! HLFIR: %[[LOAD_BOX_A_1:.*]] = fir.load %[[DECLA]]#1 : !fir.ref>>> ! CHECK: %[[C0:.*]] = arith.constant 0 : index ! CHECK: %[[DIMS0_0:.*]]:3 = fir.box_dims %[[LOAD_BOX_A_1]], %[[C0]] : (!fir.box>>, index) -> (index, index, index) ! CHECK: %[[C0:.*]] = arith.constant 0 : index @@ -136,8 +154,10 @@ subroutine acc_operand_array_section_allocatable() ! CHECK: %[[BOUND:.*]] = acc.bounds lowerbound(%[[LB]] : index) upperbound(%[[UB]] : index) stride(%[[DIMS0_1]]#2 : index) startIdx(%[[DIMS0_0]]#0 : index) {strideInBytes = true} ! CHECK: %[[BOX_ADDR:.*]] = fir.box_addr %[[LOAD_BOX_A_0]] : (!fir.box>>) -> !fir.heap> ! CHECK: %[[COPYIN:.*]] = acc.copyin varPtr(%[[BOX_ADDR]] : !fir.heap>) bounds(%[[BOUND]]) -> !fir.heap> {name = "a(1:50)"} -! CHECK: %[[LOAD_BOX_A_0:.*]] = fir.load %[[A]] : !fir.ref>>> -! CHECK: %[[LOAD_BOX_A_1:.*]] = fir.load %[[A]] : !fir.ref>>> +! FIR: %[[LOAD_BOX_A_0:.*]] = fir.load %[[A]] : !fir.ref>>> +! FIR: %[[LOAD_BOX_A_1:.*]] = fir.load %[[A]] : !fir.ref>>> +! HLFIR: %[[LOAD_BOX_A_0:.*]] = fir.load %[[DECLA]]#1 : !fir.ref>>> +! HLFIR: %[[LOAD_BOX_A_1:.*]] = fir.load %[[DECLA]]#1 : !fir.ref>>> ! CHECK: %[[C0:.*]] = arith.constant 0 : index ! CHECK: %[[DIMS0_0:.*]]:3 = fir.box_dims %[[LOAD_BOX_A_1]], %[[C0]] : (!fir.box>>, index) -> (index, index, index) ! CHECK: %[[C0:.*]] = arith.constant 0 : index @@ -168,8 +188,11 @@ subroutine acc_operand_array_section_pointer() ! CHECK-LABEL: func.func @_QMacc_data_operandPacc_operand_array_section_pointer() { ! CHECK: %[[P:.*]] = fir.alloca !fir.box>> {bindc_name = "p", uniq_name = "_QMacc_data_operandFacc_operand_array_section_pointerEp"} -! CHECK: %[[LOAD_BOX_P_0:.*]] = fir.load %[[P]] : !fir.ref>>> -! CHECK: %[[LOAD_BOX_P_1:.*]] = fir.load %[[P]] : !fir.ref>>> +! HLFIR: %[[DECLP:.*]]:2 = hlfir.declare %[[P]] {fortran_attrs = #fir.var_attrs +! FIR: %[[LOAD_BOX_P_0:.*]] = fir.load %[[P]] : !fir.ref>>> +! FIR: %[[LOAD_BOX_P_1:.*]] = fir.load %[[P]] : !fir.ref>>> +! HLFIR: %[[LOAD_BOX_P_0:.*]] = fir.load %[[DECLP]]#1 : !fir.ref>>> +! HLFIR: %[[LOAD_BOX_P_1:.*]] = fir.load %[[DECLP]]#1 : !fir.ref>>> ! CHECK: %[[C0:.*]] = arith.constant 0 : index ! CHECK: %[[DIMS0_0:.*]]:3 = fir.box_dims %[[LOAD_BOX_P_1]], %[[C0:.*]] : (!fir.box>>, index) -> (index, index, index) ! CHECK: %[[C0:.*]] = arith.constant 0 : index diff --git a/flang/test/Lower/OpenACC/acc-data.f90 b/flang/test/Lower/OpenACC/acc-data.f90 index 5226474d012c13c..c749f1948bbbe1f 100644 --- a/flang/test/Lower/OpenACC/acc-data.f90 +++ b/flang/test/Lower/OpenACC/acc-data.f90 @@ -1,6 +1,7 @@ ! This test checks lowering of OpenACC data directive. -! RUN: bbc -fopenacc -emit-fir %s -o - | FileCheck %s +! RUN: bbc -fopenacc -emit-fir %s -o - | FileCheck %s --check-prefixes=CHECK,FIR +! RUN: bbc -fopenacc -emit-hlfir %s -o - | FileCheck %s --check-prefixes=CHECK,HLFIR subroutine acc_data real, dimension(10, 10) :: a, b, c @@ -8,64 +9,88 @@ subroutine acc_data logical :: ifCondition = .TRUE. ! CHECK: %[[A:.*]] = fir.alloca !fir.array<10x10xf32> {{{.*}}uniq_name = "{{.*}}Ea"} +! HLFIR: %[[DECLA:.*]]:2 = hlfir.declare %[[A]] ! CHECK: %[[B:.*]] = fir.alloca !fir.array<10x10xf32> {{{.*}}uniq_name = "{{.*}}Eb"} +! HLFIR: %[[DECLB:.*]]:2 = hlfir.declare %[[B]] ! CHECK: %[[C:.*]] = fir.alloca !fir.array<10x10xf32> {{{.*}}uniq_name = "{{.*}}Ec"} +! HLFIR: %[[DECLC:.*]]:2 = hlfir.declare %[[C]] ! CHECK: %[[D:.*]] = fir.alloca !fir.box> {bindc_name = "d", uniq_name = "{{.*}}Ed"} +! HLFIR: %[[DECLD:.*]]:2 = hlfir.declare %[[D]] ! CHECK: %[[E:.*]] = fir.alloca !fir.box> {bindc_name = "e", uniq_name = "{{.*}}Ee"} +! HLFIR: %[[DECLE:.*]]:2 = hlfir.declare %[[E]] !$acc data if(.TRUE.) copy(a) !$acc end data ! CHECK: %[[IF1:.*]] = arith.constant true -! CHECK: %[[COPYIN:.*]] = acc.copyin varPtr(%[[A]] : !fir.ref>) bounds(%{{.*}}, %{{.*}}) -> !fir.ref> {dataClause = #acc, name = "a"} +! FIR: %[[COPYIN:.*]] = acc.copyin varPtr(%[[A]] : !fir.ref>) bounds(%{{.*}}, %{{.*}}) -> !fir.ref> {dataClause = #acc, name = "a"} +! HLFIR: %[[COPYIN:.*]] = acc.copyin varPtr(%[[DECLA]]#1 : !fir.ref>) bounds(%{{.*}}, %{{.*}}) -> !fir.ref> {dataClause = #acc, name = "a"} ! CHECK: acc.data if(%[[IF1]]) dataOperands(%[[COPYIN]] : !fir.ref>) { ! CHECK: acc.terminator ! CHECK-NEXT: }{{$}} -! CHECK: acc.copyout accPtr(%[[COPYIN]] : !fir.ref>) bounds(%{{.*}}, %{{.*}}) to varPtr(%[[A]] : !fir.ref>) {dataClause = #acc, name = "a"} +! FIR: acc.copyout accPtr(%[[COPYIN]] : !fir.ref>) bounds(%{{.*}}, %{{.*}}) to varPtr(%[[A]] : !fir.ref>) {dataClause = #acc, name = "a"} +! HLFIR: acc.copyout accPtr(%[[COPYIN]] : !fir.ref>) bounds(%{{.*}}, %{{.*}}) to varPtr(%[[DECLA]]#1 : !fir.ref>) {dataClause = #acc, name = "a"} !$acc data copy(a) if(ifCondition) !$acc end data -! CHECK: %[[COPYIN:.*]] = acc.copyin varPtr(%[[A]] : !fir.ref>) bounds(%{{.*}}, %{{.*}}) -> !fir.ref> {dataClause = #acc, name = "a"} +! FIR: %[[COPYIN:.*]] = acc.copyin varPtr(%[[A]] : !fir.ref>) bounds(%{{.*}}, %{{.*}}) -> !fir.ref> {dataClause = #acc, name = "a"} +! HLFIR: %[[COPYIN:.*]] = acc.copyin varPtr(%[[DECLA]]#1 : !fir.ref>) bounds(%{{.*}}, %{{.*}}) -> !fir.ref> {dataClause = #acc, name = "a"} ! CHECK: %[[IFCOND:.*]] = fir.load %{{.*}} : !fir.ref> ! CHECK: %[[IF2:.*]] = fir.convert %[[IFCOND]] : (!fir.logical<4>) -> i1 ! CHECK: acc.data if(%[[IF2]]) dataOperands(%[[COPYIN]] : !fir.ref>) { ! CHECK: acc.terminator ! CHECK-NEXT: }{{$}} -! CHECK: acc.copyout accPtr(%[[COPYIN]] : !fir.ref>) bounds(%{{.*}}, %{{.*}}) to varPtr(%[[A]] : !fir.ref>) {dataClause = #acc, name = "a"} +! FIR: acc.copyout accPtr(%[[COPYIN]] : !fir.ref>) bounds(%{{.*}}, %{{.*}}) to varPtr(%[[A]] : !fir.ref>) {dataClause = #acc, name = "a"} +! HLFIR: acc.copyout accPtr(%[[COPYIN]] : !fir.ref>) bounds(%{{.*}}, %{{.*}}) to varPtr(%[[DECLA]]#1 : !fir.ref>) {dataClause = #acc, name = "a"} !$acc data copy(a, b, c) !$acc end data -! CHECK: %[[COPYIN_A:.*]] = acc.copyin varPtr(%[[A]] : !fir.ref>) bounds(%{{.*}}, %{{.*}}) -> !fir.ref> {dataClause = #acc, name = "a"} -! CHECK: %[[COPYIN_B:.*]] = acc.copyin varPtr(%[[B]] : !fir.ref>) bounds(%{{.*}}, %{{.*}}) -> !fir.ref> {dataClause = #acc, name = "b"} -! CHECK: %[[COPYIN_C:.*]] = acc.copyin varPtr(%[[C]] : !fir.ref>) bounds(%{{.*}}, %{{.*}}) -> !fir.ref> {dataClause = #acc, name = "c"} +! FIR: %[[COPYIN_A:.*]] = acc.copyin varPtr(%[[A]] : !fir.ref>) bounds(%{{.*}}, %{{.*}}) -> !fir.ref... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this!
|
||
! CHECK-LABEL: acc.firstprivate.recipe @firstprivatization_ref_50xf32 : !fir.ref<!fir.array<50xf32>> init { | ||
! CHECK: ^bb0(%{{.*}}: !fir.ref<!fir.array<50xf32>>): | ||
! CHECK: %[[ALLOCA:.*]] = fir.alloca !fir.array<50xf32> | ||
! FIXME: we need hlfir.declare here to satisfy the assumptions about | ||
! the HLFIR lowering, i.e. that every varible has fir/hlfir.declare. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the review, Valentin! I wonder if you agree with this note. I do not think it is a blocker for HLFIR enabling, but I would like to create an issue to track it, if it makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I think your note is correct. I can update the recipe generation for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
This patch updates the OpenACC LIT tests to invoke HLFIR lowering in addition to FIR lowering. The tests checks were updated accordingly.
Following llvm#66099, the generation of private (and firstprivate) recipe needs to add a declare op. This patch adds the declare op for the case currently supported. This will fix issue llvm#66105.
This patch updates the OpenACC LIT tests to invoke HLFIR lowering
in addition to FIR lowering. The tests checks were updated accordingly.