Skip to content

Commit 7be1032

Browse files
authored
Update llvm-project patch files to integrate changes from #126277, #127096 and #127662 (#140)
We need to incorporate the following upstreamed patches into the 20.x branch. So applying these as patch files. [compiler-rt] Add support for big endian for Arm's __negdf2vfp - (cherry picked from llvm/llvm-project#127096) [compiler-rt] Fix tests of _aeabi(idivmod|uidivmod|uldivmod) to support big endian - (cherry picked from llvm/llvm-project#126277) [libcxx] Work around picolibc argv handling in tests - (cherry picked from llvm/llvm-project#127662)
1 parent d2609b3 commit 7be1032

11 files changed

+289
-26
lines changed

arm-software/embedded/patches/llvm-project/0001-libc-tests-with-picolibc-xfail-one-remaining-test.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From 623881f1ea465f9c1837981db143f7225108580a Mon Sep 17 00:00:00 2001
1+
From 835b3efcf5a21058dd897700fdab126781493f0d Mon Sep 17 00:00:00 2001
22
From: =?UTF-8?q?Dominik=20W=C3=B3jt?= <[email protected]>
33
Date: Mon, 16 Oct 2023 11:35:48 +0200
44
Subject: [libc++] tests with picolibc: xfail one remaining test
@@ -22,5 +22,5 @@ index d8eff69cb53f..e16048df722e 100644
2222

2323
void f() {}
2424
--
25-
2.39.5 (Apple Git-154)
25+
2.34.1
2626

arm-software/embedded/patches/llvm-project/0002-libc-tests-with-picolibc-disable-large-tests.patch

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From 8a0f8650d58f27ca32948554188b98c8978d1eb6 Mon Sep 17 00:00:00 2001
1+
From d26509789db1ef12299a530cda51357fcb020b44 Mon Sep 17 00:00:00 2001
22
From: =?UTF-8?q?Dominik=20W=C3=B3jt?= <[email protected]>
33
Date: Wed, 15 Nov 2023 12:18:35 +0100
44
Subject: [libc++] tests with picolibc: disable large tests
@@ -9,7 +9,7 @@ Subject: [libc++] tests with picolibc: disable large tests
99
2 files changed, 9 insertions(+), 2 deletions(-)
1010

1111
diff --git a/libcxx/cmake/caches/Armv7M-picolibc.cmake b/libcxx/cmake/caches/Armv7M-picolibc.cmake
12-
index b5f9089308d2..0a83e75ceceb 100644
12+
index 0f8189b45728..9e1ae0832aee 100644
1313
--- a/libcxx/cmake/caches/Armv7M-picolibc.cmake
1414
+++ b/libcxx/cmake/caches/Armv7M-picolibc.cmake
1515
@@ -18,6 +18,9 @@ set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
@@ -22,7 +22,7 @@ index b5f9089308d2..0a83e75ceceb 100644
2222
set(LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
2323
set(LIBCXX_ENABLE_EXCEPTIONS ON CACHE BOOL "")
2424
set(LIBCXX_ENABLE_FILESYSTEM OFF CACHE STRING "")
25-
@@ -30,12 +33,16 @@ set(LIBCXX_ENABLE_THREADS OFF CACHE BOOL "")
25+
@@ -30,13 +33,17 @@ set(LIBCXX_ENABLE_THREADS OFF CACHE BOOL "")
2626
set(LIBCXX_ENABLE_WIDE_CHARACTERS OFF CACHE BOOL "")
2727
set(LIBCXX_INCLUDE_BENCHMARKS OFF CACHE BOOL "")
2828
# Long tests are prohibitively slow when run via emulation.
@@ -40,8 +40,9 @@ index b5f9089308d2..0a83e75ceceb 100644
4040
+set(LIBUNWIND_TEST_PARAMS "long_tests=False;large_tests=False" CACHE STRING "")
4141
set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
4242
find_program(QEMU_SYSTEM_ARM qemu-system-arm REQUIRED)
43+
4344
diff --git a/libcxxabi/test/test_demangle.pass.cpp b/libcxxabi/test/test_demangle.pass.cpp
44-
index ad131bb3a8a7..ac612c79f71c 100644
45+
index e9c74f70a094..dee394233d37 100644
4546
--- a/libcxxabi/test/test_demangle.pass.cpp
4647
+++ b/libcxxabi/test/test_demangle.pass.cpp
4748
@@ -7,7 +7,7 @@
@@ -53,7 +54,6 @@ index ad131bb3a8a7..ac612c79f71c 100644
5354

5455
// This test exercises support for char array initializer lists added in
5556
// dd8b266ef.
56-
// UNSUPPORTED: using-built-library-before-llvm-20
5757
--
58-
2.39.5 (Apple Git-154)
58+
2.34.1
5959

arm-software/embedded/patches/llvm-project/0003-Disable-failing-compiler-rt-test.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From 0f8dc80a7642430c8d02c36283766aeb5a59a331 Mon Sep 17 00:00:00 2001
1+
From 758eaf3c1f4d4fa3b0dc1f823133635e920fade1 Mon Sep 17 00:00:00 2001
22
From: Piotr Przybyla <[email protected]>
33
Date: Wed, 15 Nov 2023 16:04:24 +0000
44
Subject: Disable failing compiler-rt test
@@ -18,5 +18,5 @@ index 2ff65a8b9ec3..98611a75e85f 100644
1818
// RUN: %clang_builtins %s %librt -o %t && %run %t
1919

2020
--
21-
2.39.5 (Apple Git-154)
21+
2.34.1
2222

arm-software/embedded/patches/llvm-project/0004-libc-tests-with-picolibc-XFAIL-uses-of-atomics.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From f5b5a95bd02f6d5bc6e80c238c2e8f7e08985d80 Mon Sep 17 00:00:00 2001
1+
From 295e2d01e88d3979aaae65214303d0a84243a4eb Mon Sep 17 00:00:00 2001
22
From: =?UTF-8?q?Dominik=20W=C3=B3jt?= <[email protected]>
33
Date: Thu, 9 Nov 2023 15:25:14 +0100
44
Subject: [libc++] tests with picolibc: XFAIL uses of atomics
@@ -88,10 +88,10 @@ index 000000000000..5ecc58f3e385
8888
+if "has-no-atomics" in config.available_features:
8989
+ config.unsupported = True
9090
diff --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py
91-
index 735eb5ac949d..6ca4e8acb3f4 100644
91+
index e4b413deff4d..dd055f1312e5 100644
9292
--- a/libcxx/utils/libcxx/test/features.py
9393
+++ b/libcxx/utils/libcxx/test/features.py
94-
@@ -215,6 +215,21 @@ DEFAULT_FEATURES = [
94+
@@ -207,6 +207,21 @@ DEFAULT_FEATURES = [
9595
""",
9696
),
9797
),
@@ -114,5 +114,5 @@ index 735eb5ac949d..6ca4e8acb3f4 100644
114114
Feature(
115115
name="32-bit-pointer",
116116
--
117-
2.39.5 (Apple Git-154)
117+
2.34.1
118118

arm-software/embedded/patches/llvm-project/0005-libc-tests-with-picolibc-mark-two-more-large-tests.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From 0961af52ac015c26829b4dae7fd6879a0b633f44 Mon Sep 17 00:00:00 2001
1+
From 061b8165660a9e3f9d7b28f9a89edf9a5a7ac57a Mon Sep 17 00:00:00 2001
22
From: =?UTF-8?q?Dominik=20W=C3=B3jt?= <[email protected]>
33
Date: Wed, 22 Nov 2023 16:12:39 +0100
44
Subject: [libc++] tests with picolibc: mark two more large tests
@@ -37,5 +37,5 @@ index 64a6a135adda..057301e6f868 100644
3737
// bool
3838
// regex_search(BidirectionalIterator first, BidirectionalIterator last,
3939
--
40-
2.39.5 (Apple Git-154)
40+
2.34.1
4141

arm-software/embedded/patches/llvm-project/0006-Define-_LIBCPP_HAS_C8RTOMB_MBRTOC8.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From 9011c0e821d5b1563dc2dc6370f29c529e55f41f Mon Sep 17 00:00:00 2001
1+
From fac938223fca26f2cbdff7fa0208c8c58decb8e8 Mon Sep 17 00:00:00 2001
22
From: Victor Campos <[email protected]>
33
Date: Thu, 31 Oct 2024 09:58:34 +0000
44
Subject: Define _LIBCPP_HAS_C8RTOMB_MBRTOC8
@@ -23,10 +23,10 @@ govern picolibc version are in `picolibc.h`.
2323
1 file changed, 2 insertions(+), 15 deletions(-)
2424

2525
diff --git a/libcxx/include/__config b/libcxx/include/__config
26-
index 1cf80a46686a..615433869a4e 100644
26+
index a866a7e65183..67ed2fbed1e3 100644
2727
--- a/libcxx/include/__config
2828
+++ b/libcxx/include/__config
29-
@@ -1021,21 +1021,8 @@ typedef __char32_t char32_t;
29+
@@ -1029,21 +1029,8 @@ typedef __char32_t char32_t;
3030
// functions is gradually being added to existing C libraries. The conditions
3131
// below check for known C library versions and conditions under which these
3232
// functions are declared by the C library.
@@ -51,5 +51,5 @@ index 1cf80a46686a..615433869a4e 100644
5151
// There are a handful of public standard library types that are intended to
5252
// support CTAD but don't need any explicit deduction guides to do so. This
5353
--
54-
2.43.0
54+
2.34.1
5555

arm-software/embedded/patches/llvm-project/0007-libcxx-Remove-xfails-due-to-picolibc-s-support-for-c.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From 2c6b08baa20bb4a7e4a936ecf286a1c9e1f0f8c9 Mon Sep 17 00:00:00 2001
1+
From 119f253eb9c95c208cd55df4f2025e3d3904525b Mon Sep 17 00:00:00 2001
22
From: Victor Campos <[email protected]>
33
Date: Thu, 31 Oct 2024 14:03:58 +0000
44
Subject: [libcxx] Remove xfails due to picolibc's support for char16_t and
@@ -43,5 +43,5 @@ index 2076384deb2b..db00cbde3336 100644
4343

4444
#include <cuchar>
4545
--
46-
2.43.0
46+
2.34.1
4747

arm-software/embedded/patches/llvm-project/0008-library-order-workaround-for-597.patch renamed to arm-software/embedded/patches/llvm-project/0008-PATCH-Revert-order-of-libraries-and-update-tests.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From 3c25466248617c03c4db62504b226f82b568be5e Mon Sep 17 00:00:00 2001
1+
From aa109995a14c1f83b47fc0999c90539112cc471e Mon Sep 17 00:00:00 2001
22
From: Volodymyr Turanskyy <[email protected]>
33
Date: Thu, 19 Dec 2024 12:01:58 +0000
44
Subject: [PATCH] Revert order of libraries and update tests
@@ -11,10 +11,10 @@ Subject: [PATCH] Revert order of libraries and update tests
1111
4 files changed, 22 insertions(+), 23 deletions(-)
1212

1313
diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp b/clang/lib/Driver/ToolChains/BareMetal.cpp
14-
index eecaaa9a4293..7d07079b5dd4 100644
14+
index ffb1c6e34d60..6df60270bd74 100644
1515
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
1616
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
17-
@@ -491,9 +491,8 @@ void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA,
17+
@@ -498,9 +498,8 @@ void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA,
1818
}
1919

2020
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
@@ -238,5 +238,5 @@ index 6d6255ef5970..08c49a1beec0 100644
238238

239239
// Check that compiler-rt library without the arch filename suffix will
240240
--
241-
2.47.0
241+
2.34.1
242242

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
From 25f3995ae6fd70a1eb0fb804229ecb5848137f96 Mon Sep 17 00:00:00 2001
2+
From: Victor Campos <[email protected]>
3+
Date: Tue, 11 Feb 2025 09:49:56 +0000
4+
Subject: [compiler-rt] Fix tests of __aeabi_(idivmod|uidivmod|uldivmod) to
5+
support big endian (#126277)
6+
7+
This patch makes these functions' tests work in big endian mode:
8+
- `__aeabi_idivmod`.
9+
- `__aeabi_uidivmod`.
10+
- `__aeabi_uldivmod`.
11+
12+
The three functions return a struct containing two fields, quotient and
13+
remainder, via *value in regs* calling convention. They differ in the
14+
integer type of each field.
15+
16+
In the tests of the first two, a 64-bit integer is used as the return
17+
type of the call. And as consequence of the ABI rules for structs
18+
(Composite Types), the quotient resides in `r0` and the remainder in
19+
`r1` regardless of endianness. So, in order to access each component
20+
from the 64-bit integer in the caller code, care must be taken to access
21+
the correct bits as they do depend on endianness in this case.
22+
23+
In the test of the third one, the caller code has inline assembly to
24+
access the components. This assembly code assumed little endian, so it
25+
had to be made flexible for big endian as well.
26+
27+
`_YUGA_BIG_ENDIAN` is defined in `int_endianness.h`. It's a macro
28+
internal to compiler-rt that's in theory compatible with more toolchains
29+
than gcc and clang.
30+
---
31+
.../builtins/Unit/arm/aeabi_idivmod_test.c | 11 +++++++++
32+
.../builtins/Unit/arm/aeabi_uidivmod_test.c | 11 +++++++++
33+
.../builtins/Unit/arm/aeabi_uldivmod_test.c | 23 ++++++++++++++++---
34+
3 files changed, 42 insertions(+), 3 deletions(-)
35+
36+
diff --git a/compiler-rt/test/builtins/Unit/arm/aeabi_idivmod_test.c b/compiler-rt/test/builtins/Unit/arm/aeabi_idivmod_test.c
37+
index ff767d754eb9..e4953bf51b03 100644
38+
--- a/compiler-rt/test/builtins/Unit/arm/aeabi_idivmod_test.c
39+
+++ b/compiler-rt/test/builtins/Unit/arm/aeabi_idivmod_test.c
40+
@@ -14,8 +14,19 @@ int test__aeabi_idivmod(si_int a, si_int b,
41+
{
42+
si_int rem;
43+
du_int ret = __aeabi_idivmod(a, b);
44+
+ // __aeabi_idivmod actually returns a struct { quotient; remainder; } using
45+
+ // value_in_regs calling convention. Due to the ABI rules, struct fields
46+
+ // come in the same order regardless of endianness. However since the
47+
+ // result is received here as a 64-bit integer, in which endianness does
48+
+ // matter, the position of each component (quotient and remainder) varies
49+
+ // depending on endianness.
50+
+# if _YUGA_BIG_ENDIAN
51+
+ rem = ret & 0xFFFFFFFF;
52+
+ si_int result = ret >> 32;
53+
+# else
54+
rem = ret >> 32;
55+
si_int result = ret & 0xFFFFFFFF;
56+
+# endif
57+
if (result != expected_result) {
58+
printf("error in __aeabi_idivmod: %d / %d = %d, expected %d\n",
59+
a, b, result, expected_result);
60+
diff --git a/compiler-rt/test/builtins/Unit/arm/aeabi_uidivmod_test.c b/compiler-rt/test/builtins/Unit/arm/aeabi_uidivmod_test.c
61+
index de5a43d5b814..a507267c4460 100644
62+
--- a/compiler-rt/test/builtins/Unit/arm/aeabi_uidivmod_test.c
63+
+++ b/compiler-rt/test/builtins/Unit/arm/aeabi_uidivmod_test.c
64+
@@ -13,8 +13,19 @@ int test__aeabi_uidivmod(su_int a, su_int b,
65+
su_int expected_result, su_int expected_rem)
66+
{
67+
du_int ret = __aeabi_uidivmod(a, b);
68+
+ // __aeabi_uidivmod actually returns a struct { quotient; remainder; }
69+
+ // using value_in_regs calling convention. Due to the ABI rules, struct
70+
+ // fields come in the same order regardless of endianness. However since
71+
+ // the result is received here as a 64-bit integer, in which endianness
72+
+ // does matter, the position of each component (quotient and remainder)
73+
+ // varies depending on endianness.
74+
+# if _YUGA_BIG_ENDIAN
75+
+ su_int rem = ret & 0xFFFFFFFF;
76+
+ si_int result = ret >> 32;
77+
+# else
78+
su_int rem = ret >> 32;
79+
si_int result = ret & 0xFFFFFFFF;
80+
+# endif
81+
82+
if (result != expected_result) {
83+
printf("error in __aeabi_uidivmod: %u / %u = %u, expected %u\n",
84+
diff --git a/compiler-rt/test/builtins/Unit/arm/aeabi_uldivmod_test.c b/compiler-rt/test/builtins/Unit/arm/aeabi_uldivmod_test.c
85+
index 98611a75e85f..2c04061a2ef6 100644
86+
--- a/compiler-rt/test/builtins/Unit/arm/aeabi_uldivmod_test.c
87+
+++ b/compiler-rt/test/builtins/Unit/arm/aeabi_uldivmod_test.c
88+
@@ -14,20 +14,37 @@ COMPILER_RT_ABI void /* __value_in_regs */ __aeabi_uldivmod(du_int a, du_int b);
89+
int test_aeabi_uldivmod(du_int a, du_int b, du_int expected_q, du_int expected_r)
90+
{
91+
du_int q, r;
92+
+ // __aeabi_uldivmod returns a struct { quotient; remainder; } using
93+
+ // value_in_regs calling convention. Each field is a 64-bit integer, so the
94+
+ // quotient resides in r0 and r1, while the remainder in r2 and r3. The
95+
+ // byte order however depends on the endianness.
96+
__asm__(
97+
+# if _YUGA_BIG_ENDIAN
98+
+ "movs r1, %Q[a] \n"
99+
+ "movs r0, %R[a] \n"
100+
+ "movs r3, %Q[b] \n"
101+
+ "movs r2, %R[b] \n"
102+
+# else
103+
"movs r0, %Q[a] \n"
104+
"movs r1, %R[a] \n"
105+
"movs r2, %Q[b] \n"
106+
"movs r3, %R[b] \n"
107+
+# endif
108+
"bl __aeabi_uldivmod \n"
109+
+# if _YUGA_BIG_ENDIAN
110+
+ "movs %Q[q], r1\n"
111+
+ "movs %R[q], r0\n"
112+
+ "movs %Q[r], r3\n"
113+
+ "movs %R[r], r2\n"
114+
+# else
115+
"movs %Q[q], r0\n"
116+
"movs %R[q], r1\n"
117+
"movs %Q[r], r2\n"
118+
"movs %R[r], r3\n"
119+
- : [q] "=r" (q), [r] "=r"(r)
120+
+# endif
121+
+ : [q] "=r"(q), [r] "=r"(r)
122+
: [a] "r"(a), [b] "r"(b)
123+
- : "lr", "r0", "r1", "r2", "r3"
124+
- );
125+
+ : "lr", "r0", "r1", "r2", "r3");
126+
if (q != expected_q || r != expected_r)
127+
printf("error in aeabi_uldivmod: %llX / %llX = %llX, R = %llX, expected %llX, %llX\n",
128+
a, b, q, r, expected_q, expected_r);
129+
--
130+
2.34.1
131+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
From 2c5da3adea204dc5e6fe4d990a34571a04e9ecb4 Mon Sep 17 00:00:00 2001
2+
From: Victor Campos <[email protected]>
3+
Date: Mon, 17 Feb 2025 11:43:36 +0000
4+
Subject: [compiler-rt] Add support for big endian for Arm's __negdf2vfp
5+
(#127096)
6+
7+
In soft floating-point ABI, this function takes the double argument as a
8+
pair of registers r0 and r1.
9+
10+
The ordering of these two registers follow the endianness rules,
11+
therefore the register on which the bit flipping must happen depends on
12+
the endianness.
13+
---
14+
compiler-rt/lib/builtins/arm/negdf2vfp.S | 6 +++++-
15+
1 file changed, 5 insertions(+), 1 deletion(-)
16+
17+
diff --git a/compiler-rt/lib/builtins/arm/negdf2vfp.S b/compiler-rt/lib/builtins/arm/negdf2vfp.S
18+
index b7cf91877e38..329c6de757f6 100644
19+
--- a/compiler-rt/lib/builtins/arm/negdf2vfp.S
20+
+++ b/compiler-rt/lib/builtins/arm/negdf2vfp.S
21+
@@ -20,7 +20,11 @@ DEFINE_COMPILERRT_FUNCTION(__negdf2vfp)
22+
#if defined(COMPILER_RT_ARMHF_TARGET)
23+
vneg.f64 d0, d0
24+
#else
25+
- eor r1, r1, #-2147483648 // flip sign bit on double in r0/r1 pair
26+
+#if _YUGA_BIG_ENDIAN
27+
+ eor r0, r0, #0x80000000 // flip sign bit on double in r0/r1 pair
28+
+#else
29+
+ eor r1, r1, #0x80000000 // flip sign bit on double in r0/r1 pair
30+
+#endif
31+
#endif
32+
bx lr
33+
END_COMPILERRT_FUNCTION(__negdf2vfp)
34+
--
35+
2.34.1
36+

0 commit comments

Comments
 (0)