Skip to content

Commit c38dbfd

Browse files
authored
[Flang] Add new Integration tests directory to Flang (#73141)
As per the RFC: [https://discourse.llvm.org/t/rfc-flang-new-directory-for-adding-end-to-end-tests-for-lowering-to-llvm-ir-in-flang/74872/11](https://discourse.llvm.org/t/rfc-flang-new-directory-for-adding-end-to-end-tests-for-lowering-to-llvm-ir-in-flang/74872/11), this patch adds a new Integration test directory for OpenMP- `flang/test/Integration/OpenMP` and moves the existing OpenMP integration tests from `flang/test/Driver/OpenMP` to this directory. **This directory can be used to add Integration tests involving multiple stages of the compiler (for eg. from Fortran to LLVM IR). It should not contain executable tests. We should only add tests here sparingly and only if there is no other way to test. Repeat this message in each test that is added to this directory and sub-directories.**
1 parent ee5749b commit c38dbfd

File tree

5 files changed

+94
-6
lines changed

5 files changed

+94
-6
lines changed

flang/test/Driver/OpenMP/host-ir-flag.f90

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
!===----------------------------------------------------------------------===!
2+
! This directory can be used to add Integration tests involving multiple
3+
! stages of the compiler (for eg. from Fortran to LLVM IR). It should not
4+
! contain executable tests. We should only add tests here sparingly and only
5+
! if there is no other way to test. Repeat this message in each test that is
6+
! added to this directory and sub-directories.
7+
!===----------------------------------------------------------------------===!
8+
9+
!RUN: %flang_fc1 -emit-llvm-bc -fopenmp -o %t.bc %s 2>&1
10+
!RUN: %flang_fc1 -emit-mlir -fopenmp -fopenmp-is-target-device -fopenmp-host-ir-file-path %t.bc -o - %s 2>&1 | FileCheck %s
11+
12+
!CHECK: module attributes {{{.*}}, omp.host_ir_filepath = "{{.*}}.bc", omp.is_gpu = false, omp.is_target_device = true{{.*}}}
13+
subroutine omp_subroutine()
14+
end subroutine omp_subroutine

flang/test/Driver/OpenMP/map-types-and-sizes.f90 renamed to flang/test/Integration/OpenMP/map-types-and-sizes.f90

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
!===----------------------------------------------------------------------===!
2+
! This directory can be used to add Integration tests involving multiple
3+
! stages of the compiler (for eg. from Fortran to LLVM IR). It should not
4+
! contain executable tests. We should only add tests here sparingly and only
5+
! if there is no other way to test. Repeat this message in each test that is
6+
! added to this directory and sub-directories.
7+
!===----------------------------------------------------------------------===!
8+
19
!RUN: %flang_fc1 -emit-llvm -fopenmp -flang-deprecated-no-hlfir %s -o - | FileCheck %s
210

311
!===============================================================================
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
!===----------------------------------------------------------------------===!
2+
! This directory can be used to add Integration tests involving multiple
3+
! stages of the compiler (for eg. from Fortran to LLVM IR). It should not
4+
! contain executable tests. We should only add tests here sparingly and only
5+
! if there is no other way to test. Repeat this message in each test that is
6+
! added to this directory and sub-directories.
7+
!===----------------------------------------------------------------------===!
8+
9+
!RUN: %flang_fc1 -emit-llvm -fopenmp %s -o - | FileCheck %s --check-prefixes HOST,ALL
10+
!RUN: %flang_fc1 -emit-llvm -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefixes DEVICE,ALL
11+
12+
!HOST: define {{.*}}@{{.*}}before{{.*}}(
13+
!DEVICE-NOT: define {{.*}}@before{{.*}}(
14+
!DEVICE-NOT: declare {{.*}}@before{{.*}}
15+
integer function before(x)
16+
integer, intent(in) :: x
17+
before = x + 200
18+
end function
19+
20+
!ALL: define {{.*}}@{{.*}}main{{.*}}(
21+
program main
22+
integer :: x, before, after
23+
!$omp target map(tofrom : x)
24+
x = 100
25+
!$omp end target
26+
!HOST: call {{.*}}@{{.*}}before{{.*}}(
27+
!DEVICE-NOT: call {{.*}}@before{{.*}}(
28+
!HOST: call {{.*}}@{{.*}}after{{.*}}(
29+
!DEVICE-NOT: call {{.*}}@after{{.*}}(
30+
x = x + before(x) + after(x)
31+
end program
32+
33+
!HOST: define {{.*}}@{{.*}}after{{.*}}(
34+
!DEVICE-NOT: define {{.*}}@after{{.*}}(
35+
!DEVICE-NOT: declare {{.*}}@after{{.*}}
36+
integer function after(x)
37+
integer, intent(in) :: x
38+
after = x + 300
39+
end function
40+
41+
!ALL: define {{.*}}@{{.*}}before_target{{.*}}(
42+
subroutine before_target(x)
43+
integer, intent(out) :: x
44+
!$omp target map(from: x)
45+
x = 1
46+
!$omp end target
47+
end subroutine
48+
49+
!ALL: define {{.*}}@{{.*}}middle{{.*}}(
50+
subroutine middle()
51+
integer :: x
52+
!$omp target map(from: x)
53+
x = 0
54+
!$omp end target
55+
!HOST: call {{.*}}@{{.*}}before_target{{.*}}(
56+
!DEVICE-NOT: call {{.*}}@{{.*}}before_target{{.*}}(
57+
!HOST: call {{.*}}@{{.*}}after_target{{.*}}(
58+
!DEVICE-NOT: call {{.*}}@{{.*}}after_target{{.*}}(
59+
call before_target(x)
60+
call after_target(x)
61+
end subroutine
62+
63+
!ALL: define {{.*}}@{{.*}}after_target{{.*}}(
64+
subroutine after_target(x)
65+
integer, intent(out) :: x
66+
!$omp target map(from:x)
67+
x = 2
68+
!$omp end target
69+
end subroutine

flang/test/Integration/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Flang Integration Tests
2+
3+
This directory can be used to add Integration tests involving multiple stages of the compiler (for eg. from Fortran to LLVM IR). It should not contain executable tests. We should only add tests here sparingly and only if there is no other way to test. Repeat this message in each test that is added to this directory and sub-directories.

0 commit comments

Comments
 (0)