diff --git a/openmp/CMakeLists.txt b/openmp/CMakeLists.txt index c206386fa6b61..671602c1f8732 100644 --- a/openmp/CMakeLists.txt +++ b/openmp/CMakeLists.txt @@ -68,11 +68,9 @@ else() endif() # Check for flang - if (NOT MSVC) - set(OPENMP_TEST_Fortran_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/flang) - else() - set(OPENMP_TEST_Fortran_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/flang.exe) - endif() + set(OPENMP_TEST_Fortran_COMPILER ${CMAKE_Fortran_COMPILER} CACHE STRING + "FORTRAN compiler to use for testing OpenMP runtime libraries.") + # Set fortran test compiler if flang is found if (EXISTS "${OPENMP_TEST_Fortran_COMPILER}") diff --git a/openmp/README.rst b/openmp/README.rst index 2dfc8630858b8..553dce5647cd7 100644 --- a/openmp/README.rst +++ b/openmp/README.rst @@ -119,6 +119,10 @@ Options for all Libraries Compiler to use for testing. Defaults to the compiler that was also used for building. +**OPENMP_TEST_Fortran_COMPILER** = ``${CMAKE_Fortran_COMPILER}`` + Compiler to use for testing. Defaults to the compiler that was also used for + building. + **OPENMP_TEST_Fortran_COMPILER** = ``${CMAKE_Fortran_COMPILER}`` Compiler to use for testing. Defaults to the compiler that was also used for building. Will default to flang if build is in-tree. diff --git a/openmp/runtime/test/lit.cfg b/openmp/runtime/test/lit.cfg index ca32985fe6c48..2f2593622630d 100644 --- a/openmp/runtime/test/lit.cfg +++ b/openmp/runtime/test/lit.cfg @@ -39,6 +39,12 @@ config.name = 'libomp' # suffixes: A list of file extensions to treat as test files. config.suffixes = ['.c', '.cpp'] +if config.test_fortran_compiler: + lit_config.note("OpenMP Fortran tests enabled") + config.suffixes += ['.f90'] +else: + lit_config.note("OpenMP Fortran tests disabled") + # test_source_root: The root path where tests are located. config.test_source_root = os.path.dirname(__file__) @@ -225,3 +231,13 @@ if config.has_ompt: config.substitutions.append(("%no-as-needed-flag", "-Wl,--no-as-needed")) else: config.substitutions.append(("FileCheck", config.test_filecheck)) + +tools = [ + ToolSubst( + "%flang", + command=config.test_fortran_compiler, + unresolved="fatal", + ), +] + +llvm_config.add_tool_substitutions(tools, [config.llvm_tools_dir]) diff --git a/openmp/runtime/test/lit.site.cfg.in b/openmp/runtime/test/lit.site.cfg.in index fc65289e4ce64..cc8b3b252d7d1 100644 --- a/openmp/runtime/test/lit.site.cfg.in +++ b/openmp/runtime/test/lit.site.cfg.in @@ -2,6 +2,7 @@ config.test_c_compiler = "@OPENMP_TEST_C_COMPILER@" config.test_cxx_compiler = "@OPENMP_TEST_CXX_COMPILER@" +config.test_fortran_compiler = "@OPENMP_TEST_Fortran_COMPILER@" config.test_compiler_features = @OPENMP_TEST_COMPILER_FEATURES@ config.test_compiler_has_omp_h = @OPENMP_TEST_COMPILER_HAS_OMP_H@ config.test_filecheck = "@OPENMP_FILECHECK_EXECUTABLE@" @@ -24,6 +25,7 @@ config.has_omit_frame_pointer_flag = @OPENMP_TEST_COMPILER_HAS_OMIT_FRAME_POINTE config.target_arch = "@LIBOMP_ARCH@" config.compiler_frontend_variant = "@CMAKE_C_COMPILER_FRONTEND_VARIANT@" config.compiler_simulate_id = "@CMAKE_C_SIMULATE_ID@" +config.llvm_tools_dir = "@LLVM_TOOLS_DIR@" import lit.llvm lit.llvm.initialize(lit_config, config) diff --git a/openmp/runtime/test/transform/unroll/heuristic_intdo.f90 b/openmp/runtime/test/transform/unroll/heuristic_intdo.f90 new file mode 100644 index 0000000000000..d0ef938dd3a8f --- /dev/null +++ b/openmp/runtime/test/transform/unroll/heuristic_intdo.f90 @@ -0,0 +1,26 @@ +! This test checks lowering of OpenMP unroll directive + +! RUN: %flang %flags %openmp_flags -fopenmp-version=51 %s -o %t.exe +! RUN: %t.exe | FileCheck %s --match-full-lines + + +program unroll_heuristic + integer :: i + print *, 'do' + + !$OMP UNROLL + do i=7, 18, 3 + print '("i=", I0)', i + end do + !$OMP END UNROLL + + print *, 'done' +end program + + +! CHECK: do +! CHECK-NEXT: i=7 +! CHECK-NEXT: i=10 +! CHECK-NEXT: i=13 +! CHECK-NEXT: i=16 +! CHECK-NEXT: done