Index: openmp/README.rst =================================================================== --- openmp/README.rst +++ openmp/README.rst @@ -130,6 +130,10 @@ Specify full path to ``FileCheck`` executable for running tests. The default is to search the ``PATH`` and the directory in **OPENMP_LLVM_TOOLS_DIR**. +**OPENMP_NOT_EXECUTABLE** = ``/path/to/not`` + Specify full path to ``not`` executable for running tests. The default + is to search the ``PATH`` and the directory in **OPENMP_LLVM_TOOLS_DIR**. + Options for ``libomp`` ---------------------- Index: openmp/cmake/OpenMPTesting.cmake =================================================================== --- openmp/cmake/OpenMPTesting.cmake +++ openmp/cmake/OpenMPTesting.cmake @@ -34,6 +34,17 @@ set(ENABLE_CHECK_TARGETS FALSE PARENT_SCOPE) return() endif() + + find_program(OPENMP_NOT_EXECUTABLE + NAMES not + PATHS ${OPENMP_LLVM_TOOLS_DIR}) + if (NOT OPENMP_NOT_EXECUTABLE) + message(STATUS "Cannot find 'not'.") + message(STATUS "Please put 'not' in your PATH, set OPENMP_NOT_EXECUTABLE to its full path, or point OPENMP_LLVM_TOOLS_DIR to its directory.") + message(WARNING "The check targets will not be available!") + set(ENABLE_CHECK_TARGETS FALSE PARENT_SCOPE) + return() + endif() endfunction() if (${OPENMP_STANDALONE_BUILD}) @@ -55,6 +66,7 @@ separate_arguments(OPENMP_LIT_ARGS) else() set(OPENMP_FILECHECK_EXECUTABLE ${LLVM_RUNTIME_OUTPUT_INTDIR}/FileCheck) + set(OPENMP_NOT_EXECUTABLE ${LLVM_RUNTIME_OUTPUT_INTDIR}/not) endif() # Macro to extract information about compiler from file. (no own scope) Index: openmp/libomptarget/src/omptarget.cpp =================================================================== --- openmp/libomptarget/src/omptarget.cpp +++ openmp/libomptarget/src/omptarget.cpp @@ -286,6 +286,7 @@ // NULL, so getOrAlloc() returning NULL is not an error. DP("Call to getOrAllocTgtPtr returned null pointer (device failure or " "illegal mapping).\n"); + return OFFLOAD_FAIL; } DP("There are %" PRId64 " bytes allocated at target address " DPxMOD " - is%s new\n", data_size, DPxPTR(TgtPtrBegin), Index: openmp/libomptarget/test/lit.cfg =================================================================== --- openmp/libomptarget/test/lit.cfg +++ openmp/libomptarget/test/lit.cfg @@ -101,6 +101,9 @@ config.substitutions.append(("%libomptarget-run-" + \ libomptarget_target, \ "%t-" + libomptarget_target)) + config.substitutions.append(("%libomptarget-run-fail-" + \ + libomptarget_target, \ + config.libomptarget_not + " %t-" + libomptarget_target)) config.substitutions.append(("%clangxx-" + libomptarget_target, \ "%clangxx %openmp_flags %flags -fopenmp-targets=" + libomptarget_target)) config.substitutions.append(("%clang-" + libomptarget_target, \ @@ -129,6 +132,9 @@ config.substitutions.append(("%libomptarget-run-" + \ libomptarget_target, \ "echo ignored-command")) + config.substitutions.append(("%libomptarget-run-fail-" + \ + libomptarget_target, \ + "echo ignored-command")) config.substitutions.append(("%clang-" + libomptarget_target, \ "echo ignored-command")) config.substitutions.append(("%clangxx-" + libomptarget_target, \ Index: openmp/libomptarget/test/lit.site.cfg.in =================================================================== --- openmp/libomptarget/test/lit.site.cfg.in +++ openmp/libomptarget/test/lit.site.cfg.in @@ -13,6 +13,7 @@ config.libomptarget_all_targets = "@LIBOMPTARGET_ALL_TARGETS@".split() config.libomptarget_system_targets = "@LIBOMPTARGET_SYSTEM_TARGETS@".split() config.libomptarget_filecheck = "@OPENMP_FILECHECK_EXECUTABLE@" +config.libomptarget_not = "@OPENMP_NOT_EXECUTABLE@" config.libomptarget_debug = @LIBOMPTARGET_DEBUG@ # Let the main config do the real work. Index: openmp/libomptarget/test/mapping/alloc_fail.c =================================================================== --- /dev/null +++ openmp/libomptarget/test/mapping/alloc_fail.c @@ -0,0 +1,25 @@ +// RUN: %libomptarget-compile-aarch64-unknown-linux-gnu +// RUN: %libomptarget-run-fail-aarch64-unknown-linux-gnu 2>&1 \ +// RUN: | %fcheck-aarch64-unknown-linux-gnu + +// RUN: %libomptarget-compile-powerpc64-ibm-linux-gnu +// RUN: %libomptarget-run-fail-powerpc64-ibm-linux-gnu 2>&1 \ +// RUN: | %fcheck-powerpc64-ibm-linux-gnu + +// RUN: %libomptarget-compile-powerpc64le-ibm-linux-gnu +// RUN: %libomptarget-run-fail-powerpc64le-ibm-linux-gnu 2>&1 \ +// RUN: | %fcheck-powerpc64le-ibm-linux-gnu + +// RUN: %libomptarget-compile-x86_64-pc-linux-gnu +// RUN: %libomptarget-run-fail-x86_64-pc-linux-gnu 2>&1 \ +// RUN: | %fcheck-x86_64-pc-linux-gnu + +// CHECK: Libomptarget fatal error 1: failure of target construct while offloading is mandatory + +int main() { + int arr[4] = {0, 1, 2, 3}; +#pragma omp target data map(alloc: arr[0:2]) +#pragma omp target data map(alloc: arr[1:2]) + ; + return 0; +}