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,49 @@ +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 "..."` without `{ target` afterwards (ignoring + # whitespace). + if(FileFirstLine MATCHES "dg-options \"([^\"]*)\" *[^{]") + # This is needed to turn the string into a list of CFLAGS + separate_arguments(FILE_CFLAGS UNIX_COMMAND ${CMAKE_MATCH_1}) + list(APPEND CFLAGS ${FILE_CFLAGS}) + endif() + endforeach() + endfunction() + + # Execute-style tests + # + # These will compile and then execute + function(gcc_torture_execute_test File) + get_filename_component(Name ${File} NAME_WE) + set(_target "torture-${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() + + macro(gcc_torture_subdir DIR) + string(REPLACE "/" "-" TORTURE_NAME_PREFIX ${DIR}) + set(TORTURE_DIR "${TEST_SUITE_GCC_C_TORTURE_ROOT}/${DIR}") + add_subdirectory(${DIR}) + endmacro() + + # gcc_torture_subdir(compile) + + gcc_torture_subdir(execute) + gcc_torture_subdir(execute/ieee) + + 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,15 @@ +# 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 Index: External/gcc-c-torture/execute/CMakeLists.txt =================================================================== --- /dev/null +++ External/gcc-c-torture/execute/CMakeLists.txt @@ -0,0 +1,188 @@ +# 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 failure even on clang x86 + 20021127-1.c + 20031003-1.c + alloca-1.c + bitfld-3.c + bitfld-5.c + eeprof-1.c + pr32244-1.c + pr34971.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 + + # x86 only + 990413-2.c + + # Unsupported builtins, even on x86 clang + 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, even on x86 clang + medce-1.c + + # Clang does not support 'DD' suffix on floating constant + pr80692.c + + # Requires definitions of stdout/stderr + fprintf-1.c + fprintf-chk-1.c + gofast.c + vfprintf-1.c + vfprintf-chk-1.c + + # 64-bit Multiply-with-overflow expands to a __mulodi4, which is present in + # compiler-rt but not libgcc + pr71554.c + pr89434.c + + # __muloti4 is present in compiler-rt but not libgcc + pr84169.c + + # __assert_fail is not defined in newlib + pr58831.c + + # No support for __builtin_longjmp/__builtin_setjmp. Also true of clang for + # AArch64. + built-in-setjmp.c + pr60003.c + pr64242.c + pr84521.c + + # Test depends on Clang having the same __builtin_constant_p(x) behaviour as gcc. + # Fails on Clang x86-64 with optimisation enabled + builtin-constant.c + + # pragma optimize("-option") is ignored by Clang + alias-1.c + pr79043.c + + # Expects that function is always inlined + 990208-1.c + + # Checks optimiser-specific behaviour, also fails on Clang x86 with O1 + printf-chk-1.c + vprintf-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 + + # clang doesn't support __builtin_shuffle + pr85331.c + + # Fails on gcc too, newlib presumably newlib fails to support %hhd + pr78622.c + + # __builtin_return_address(n) with n > 0 not guaranteed to give expected result + 20010122-1.c +) + +if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "riscv") + list(APPEND TestsToSkip + # clang complains the array is too large on RV64 + 991014-1.c + + # Requires int128 support (not present on RV32) + pr84748.c + + # Can't open file with newlib+pk+spike + fprintf-2.c + printf-2.c + user-printf.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() \ 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