diff --git a/0001-gcc-c-torture-Disable-frame-address.c-test-due-to-in.patch b/0001-gcc-c-torture-Disable-frame-address.c-test-due-to-in.patch new file mode 100644 index 0000000..53f7235 --- /dev/null +++ b/0001-gcc-c-torture-Disable-frame-address.c-test-due-to-in.patch @@ -0,0 +1,87 @@ +From 259fcdabfd843d01fccd9a1aeb44642e9043a883 Mon Sep 17 00:00:00 2001 +From: David Spickett +Date: Wed, 15 Mar 2023 15:19:11 +0000 +Subject: [PATCH] [gcc-c-torture] Disable frame-address.c test due to incorrect + tail call prevention + +These checks were added to the original test by: +https://github.com/gcc-mirror/gcc/commit/0f149d5215a22a03406a82ec1669bf65b329a4df + +Since 6b545db83c5a4e2c79e0b289e840be2c5fbbf327, clang has learned +to see through this tail call prevention. + +First seen by us on our SVE bot which runs the test suite at -O3: +https://lab.llvm.org/buildbot/#/builders/197/builds/4192 + +Clang is correct here, this is why: +``` +int check_fa_work (const char *c, const char *f) +{ + const char d = 0; + + if (c >= &d) + return c >= f && f >= &d; + else + return c <= f && f <= &d; +} +``` +This function only ever returns 0 or 1 due to the `&&`. +``` +int check_fa_mid (const char *c) +{ + const char *f = __builtin_frame_address (0); + + /* Prevent a tail call to check_fa_work, eliding the current stack frame. */ + return check_fa_work (c, f) != 0; +} +``` +This function returns whether the result of check_fa_work is not equal to 0. + +Clang has realised that if check_fa_work returns 0, check_fa_mid does also. +Same for 1. Meaning you can tail call check_fa_work. + +check_fa_work returns 0, 0 != 0 is False, so check_fa_mid returns 0 +check_fa_work returns 1, 1 != 0 is True, so check_fa_mid returns 1 + +Giving you asm like: +``` +check_fa_mid: // @check_fa_mid + stp x29, x30, [sp, #-16]! // 16-byte Folded Spill + mov x29, sp + mov x1, x29 + ldp x29, x30, [sp], #16 // 16-byte Folded Reload + b check_fa_work +``` +Which means we have one less frame and the test fails. + +A correct way to do it would be "==" which would have to invert the result. +However we cannot modify the test files, so disable the test instead. + +I have filed a bug with gcc: +https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109146 + +Reviewed By: lenary + +Differential Revision: https://reviews.llvm.org/D146143 +--- + .../Regression/C/gcc-c-torture/execute/CMakeLists.txt | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/SingleSource/Regression/C/gcc-c-torture/execute/CMakeLists.txt b/SingleSource/Regression/C/gcc-c-torture/execute/CMakeLists.txt +index acbc0798..630fa7e3 100644 +--- a/SingleSource/Regression/C/gcc-c-torture/execute/CMakeLists.txt ++++ b/SingleSource/Regression/C/gcc-c-torture/execute/CMakeLists.txt +@@ -140,6 +140,10 @@ file(GLOB UnsupportedTests CONFIGURE_DEPENDS + # Size of array element is not a multiple of its alignment. + pr36093.c + pr43783.c ++ ++ # Uses an incorrect method to prevent tailcalls which clang at -O1 or above ++ # can see through and tail call regardless. ++ frame-address.c + ) + list(APPEND TestsToSkip ${UnsupportedTests}) + +-- +2.44.0 + diff --git a/0001-gcc-c-torture-use-fwrapv-for-950704-1.c-signed-overf.patch b/0001-gcc-c-torture-use-fwrapv-for-950704-1.c-signed-overf.patch new file mode 100644 index 0000000..8acba9e --- /dev/null +++ b/0001-gcc-c-torture-use-fwrapv-for-950704-1.c-signed-overf.patch @@ -0,0 +1,26 @@ +From d10245e73a71cee2beb737863ffe8f146f4d47e0 Mon Sep 17 00:00:00 2001 +From: antoine moynault +Date: Thu, 21 Dec 2023 16:41:50 +0100 +Subject: [PATCH] [gcc-c-torture] use -fwrapv for 950704-1.c (signed overflow) + (#70) + +test fails since #76044 +--- + SingleSource/Regression/C/gcc-c-torture/execute/CMakeLists.txt | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/SingleSource/Regression/C/gcc-c-torture/execute/CMakeLists.txt b/SingleSource/Regression/C/gcc-c-torture/execute/CMakeLists.txt +index 4788755c..03425811 100644 +--- a/SingleSource/Regression/C/gcc-c-torture/execute/CMakeLists.txt ++++ b/SingleSource/Regression/C/gcc-c-torture/execute/CMakeLists.txt +@@ -181,6 +181,7 @@ file(GLOB TestRequiresFWrapV CONFIGURE_DEPENDS + 20040409-1.c + 20040409-2.c + 20040409-3.c ++ 950704-1.c + ) + + # Tests that require -Wno-return-type +-- +2.44.0 + diff --git a/llvm-test-suite.spec b/llvm-test-suite.spec index b33fe9d..59bff59 100644 --- a/llvm-test-suite.spec +++ b/llvm-test-suite.spec @@ -6,7 +6,7 @@ Name: llvm-test-suite Version: %{llvm_test_suite_version}%{?rc_ver:~rc%{rc_ver}} -Release: 1%{?dist} +Release: 2%{?dist} Summary: C/C++ Compiler Test Suite License: NCSA and BSD and GPLv1 and GPLv2+ and GPLv2 and MIT and Python and Public Domain and CRC32 and AML and Rdisc and ASL 2.0 and LGPLv3 @@ -28,6 +28,8 @@ Source2: pkg_test_suite.sh BuildArch: noarch Patch0: 0001-Fix-extra-Python3-print-statements.patch +Patch1: 0001-gcc-c-torture-Disable-frame-address.c-test-due-to-in.patch +Patch2: 0001-gcc-c-torture-use-fwrapv-for-950704-1.c-signed-overf.patch # We need python3-devel for pathfix.py. BuildRequires: python3-devel @@ -82,6 +84,9 @@ cp -R %{_builddir}/%{test_suite_srcdir}/* %{buildroot}%{_datadir}/llvm-test-suit %changelog +* Tue Apr 16 2024 Tulio Magno Quites Machado Filho - 16.0.6-2 +- Backport 2 fixes from upstream + * Mon Jul 10 2023 Tulio Magno Quites Machado Filho - 16.0.6-1 - Update to LLVM 16.0.6