Index: External/CMakeLists.txt =================================================================== --- External/CMakeLists.txt +++ External/CMakeLists.txt @@ -1,4 +1,5 @@ add_subdirectory(CUDA) +add_subdirectory(gcc-c-torture) add_subdirectory(HMMER) add_subdirectory(Nurbs) add_subdirectory(Povray) Index: External/gcc-c-torture/CMakeLists.txt =================================================================== --- /dev/null +++ External/gcc-c-torture/CMakeLists.txt @@ -0,0 +1,56 @@ +include(External) +llvm_externals_find(TEST_SUITE_GCC_C_TORTURE_ROOT "gcc-c-torture" "GCC C Torture Suite") +if(TEST_SUITE_GCC_C_TORTURE_ROOT) + + function(gcc_torture_dg_options_cflags File) + # Some files have dg-options which we need to pick up. These should be in + # the first line but often aren't. + # + # We also need to be careful not to pick up target-specific dg-options. + file(STRINGS ${File} FileLines) + foreach(FileLine ${FileLines}) + # Looking for `dg-options "..."` or `dg-additional-options "..."` without + # `{ target` afterwards (ignoring spaces). + if(FileFirstLine MATCHES "dg-(additional-)?options \"([^\"]*)\" *[^{]") + # This is needed to turn the string into a list of CFLAGS + separate_arguments(FILE_CFLAGS UNIX_COMMAND ${CMAKE_MATCH_2}) + list(APPEND CFLAGS ${FILE_CFLAGS}) + endif() + endforeach() + endfunction() + + # Execute-style tests + # + # These will compile and then execute + function(gcc_torture_execute_test File) + # There are a few tests with duplicate filenames, and CMake wants all target + # names to be unique, so we add a disambiguator to the target name. The + # disambuguator is based upon the directory structure, swapping `/` for `-`. + get_filename_component(Name ${File} NAME_WE) + set(_target "${TORTURE_NAME_PREFIX}-${Name}") + + gcc_torture_dg_options_cflags(${File}) + + llvm_test_executable_no_test(${_target} ${File}) + llvm_test_run() + llvm_add_test_for_target(${_target}) + endfunction() + + + set(TORTURE_NAME_PREFIX "torture") + set(TORTURE_DIR "${TEST_SUITE_GCC_C_TORTURE_ROOT}") + + macro(gcc_torture_subdir DIR) + # Disambuguator prefix for target names + set(TORTURE_NAME_PREFIX "${TORTURE_NAME_PREFIX}-${DIR}") + + # This is used to find the test sources in $TEST_SUITE_GCC_C_TORTURE_ROOT + set(TORTURE_DIR "${TORTURE_DIR}/${DIR}") + add_subdirectory(${DIR}) + endmacro() + + gcc_torture_subdir(execute) + + file(COPY lit.local.cfg DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") + +endif() \ No newline at end of file Index: External/gcc-c-torture/README =================================================================== --- /dev/null +++ External/gcc-c-torture/README @@ -0,0 +1,23 @@ +# GCC C Torture Suite + +This external test suite requires an export of +svn://gcc.gnu.org/svn/gcc/trunk/gcc/testsuite/gcc.c-torture at either +llvm-test-suite/test-suite-externals/gcc-c-torture or at +$TEST_SUITE_GCC_C_TORTURE_ROOT + +Last checked at SVN version 275024 + +A command-line invocation to do a SVN Export at that revision might look like +the following, if run from the root of llvm-test-suite: + + $ svn export -r 275024 \ + svn://gcc.gnu.org/svn/gcc/trunk/gcc/testsuite/gcc.c-torture \ + test-suite-externals/gcc-c-torture + +You may also have better luck using the test suite from the following repo: + https://github.com/embecosm/gcc-for-llvm-testing + +# Platform-specific concerns + +RISC-V: The list of tests to exclude on RISC-V was devised using glibc and qemu. +You may have to exclude additional tests when running with newlib and/or spike. \ No newline at end of file Index: External/gcc-c-torture/execute/CMakeLists.txt =================================================================== --- /dev/null +++ External/gcc-c-torture/execute/CMakeLists.txt @@ -0,0 +1,178 @@ +# The list of tests to skip is probably too long for this file +set(TestsToSkip + # Nested functions, unsupported in clang + 20000822-1.c + 20010209-1.c + 20010605-1.c + 20030501-1.c + 20040520-1.c + 20061220-1.c + 20090219-1.c + 920415-1.c + 920428-2.c + 920501-7.c + 920612-2.c + 920721-4.c + 921017-1.c + 921215-1.c + 931002-1.c + comp-goto-2.c + nest-align-1.c + nest-stdar-1.c + nestfunc-1.c + nestfunc-2.c + nestfunc-3.c + nestfunc-5.c + nestfunc-6.c + nestfunc-7.c + pr22061-3.c + pr22061-4.c + pr24135.c + pr51447.c + pr71494.c + + # Expects gnu89 inline behaviour + 20001121-1.c + 20020107-1.c + 930526-1.c + 961223-1.c + 980608-1.c + bcp-1.c + loop-2c.c + p18298.c + restrict-1.c + unroll-1.c + va-arg-7.c + va-arg-8.c + + # Variable length arrays in structs, unsupported in clang + 20020412-1.c + 20040308-1.c + 20040423-1.c + 20041218-2.c + 20070919-1.c + align-nest.c + pr41935.c + pr82210.c + + # Initialization of flexible array member unsupported in clang + pr28865.c + + # Runtime failures + 20021127-1.c + 20031003-1.c + bitfld-3.c + bitfld-5.c + eeprof-1.c + noinit-attribute.c + pr32244-1.c + pr34971.c + + # No support for __builtin_longjmp/__builtin_setjmp + pr60003.c + pr64242.c + + # Clang has no __builtin_malloc + 20071018-1.c + 20071120-1.c + pr36765.c + pr43008.c + pr84339.c + pr84478.c + strlen-7.c + + # Non-void function must return a value + 920302-1.c + 920501-3.c + 920728-1.c + + # Must link with libm + 980709-1.c + float-floor.c + + # Unsupported builtins + builtin-bitops-1.c + pr39228.c + pr47237.c + pr78586.c + pr79327.c + va-arg-pack-1.c + + # Requires mmap + loop-2f.c + loop-2g.c + + # Link error + medce-1.c + + # Clang does not support 'DD' suffix on floating constant + pr80692.c + + # __muloti4 is present in compiler-rt but not libgcc + pr84169.c + + # clang doesn't support __builtin_shuffle + pr85331.c + + # __builtin_return_address(n) with n > 0 not guaranteed to give expected result + 20010122-1.c + + # Checks optimiser-specific behaviour + printf-chk-1.c + fprintf-chk-1.c + vprintf-chk-1.c + vfprintf-chk-1.c + + # Test relies on undefined signed overflow behaviour (int foo - INT_MIN). + # Should really require -fwrapv + 20040409-1.c + 20040409-2.c + 20040409-3.c + + # These have -fwrapv but still give runtime issues + 20040409-1w.c + 20040409-2w.c + 20040409-3w.c + 920612-1.c + pr22493-1.c + pr23047.c + + # This infinite loops with -O3 + 930529-1.c + + # clang complains the array is too large + 991014-1.c + + # Expects that function is always inlined + 990208-1.c + + # pragma optimize("-option") is ignored by Clang + alias-1.c + pr79043.c + + # Flags -fnon-call-exceptions + 20101011-1.c +) + +if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "riscv") + list(APPEND TestsToSkip + # x86 Only + 990413-2.c + + # No support for __builtin_longjmp/__builtin_setjmp + built-in-setjmp.c + pr84521.c + + ) +endif() + +file(GLOB TestFiles "${TORTURE_DIR}/*.c") +foreach(SkipFile ${TestsToSkip}) + list(REMOVE_ITEM TestFiles "${TORTURE_DIR}/${SkipFile}") +endforeach() + +foreach(File ${TestFiles}) + gcc_torture_execute_test(${File}) +endforeach() + +gcc_torture_subdir(ieee) \ No newline at end of file Index: External/gcc-c-torture/execute/ieee/CMakeLists.txt =================================================================== --- /dev/null +++ External/gcc-c-torture/execute/ieee/CMakeLists.txt @@ -0,0 +1,18 @@ +set(TestsToSkip + # Must link with libm + 20041213-1.c + mzero4.c + + # Clang at O0 does not work out the code referencing the undefined symbol can + # never be executed + fp-cmp-7.c +) + +file(GLOB TestFiles "${TORTURE_DIR}/*.c") +foreach(SkipFile ${TestsToSkip}) + list(REMOVE_ITEM TestFiles "${TORTURE_DIR}/${SkipFile}") +endforeach() + +foreach(File ${TestFiles}) + gcc_torture_execute_test(${File}) +endforeach() \ No newline at end of file Index: External/gcc-c-torture/lit.local.cfg =================================================================== --- /dev/null +++ External/gcc-c-torture/lit.local.cfg @@ -0,0 +1 @@ +config.single_source = True