[libcxx-commits] [libcxx] [libcxxabi] [WIP] [libcxx] PR testrun (ignore) (PR #123570)
Martin Storsjö via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Apr 7 05:40:22 PDT 2025
https://github.com/mstorsjo updated https://github.com/llvm/llvm-project/pull/123570
>From 1c5555e2843fcc54d1a44cc4dbdd77885646df70 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin at martin.st>
Date: Wed, 12 Mar 2025 22:44:09 +0200
Subject: [PATCH 1/3] [libcxx] [test] Fix the condition for long double hex
formatting
This test currently hardcodes which environments have got 80 bit
long doubles on x86_64; add a check for the actual size of
the long doubles as well. This allows waiving this test for
x86_64 configurations with a different size of long doubles.
---
.../facet.num.put.members/put_long_double.hex.pass.cpp | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/libcxx/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.hex.pass.cpp b/libcxx/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.hex.pass.cpp
index b9b02f5ea7b67..25c0291c58c75 100644
--- a/libcxx/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.hex.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.hex.pass.cpp
@@ -1846,11 +1846,10 @@ void test1() {
void test2() {
std::locale lc = std::locale::classic();
std::locale lg(lc, new my_numpunct);
-#if (defined(__APPLE__) || defined(TEST_HAS_GLIBC) || defined(__MINGW32__)) && defined(__x86_64__)
+#if (defined(__APPLE__) || defined(TEST_HAS_GLIBC) || defined(__MINGW32__)) && defined(__x86_64__) && __LDBL_MANT_DIG__ == 64
// This test is failing on FreeBSD, possibly due to different representations
// of the floating point numbers.
- // This test is failing in MSVC environments, where long double is equal to regular
- // double, and instead of "0x9.32c05a44p+27", this prints "0x1.26580b4880000p+30".
+ // This test assumes that long doubles are x87 80 bit long doubles.
const my_facet f(1);
char str[200];
{
>From 1504dcaba6072d473bdeba46a43b1277e2d7e18f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin at martin.st>
Date: Wed, 12 Mar 2025 23:46:56 +0200
Subject: [PATCH 2/3] [libcxxabi] Use __LDBL_MANT_DIG__ for configuring
demangling of long doubles
This avoids needing to hardcode the mapping between architectures
and their sizes of long doubles.
This fixes a case in test_demangle.pass.cpp, that previously failed
like this:
.---command stdout------------
| Testing 29859 symbols.
| _ZN5test01hIfEEvRAcvjplstT_Le4001a000000000000000E_c should be invalid but is not
| Got: 0, void test0::h<float>(char (&) [(unsigned int)(sizeof (float) + 0x0.07ff98f7ep-1022L)])
`-----------------------------
.---command stderr------------
| Assertion failed: !passed && "demangle did not fail", file libcxxabi/test/test_demangle.pass.cpp, line 30338
`-----------------------------
This testcase is defined within
// Is long double fp80? (Only x87 extended double has 64-bit mantissa)
#define LDBL_FP80 (__LDBL_MANT_DIG__ == 64)
...
#if !LDBL_FP80
...
#endif
The case failed, by unexpectedly passing, when the demangler was
capable of demangling an 80 bit long double, while the compiler
actually is configured for a different size for that type.
---
libcxxabi/src/demangle/ItaniumDemangle.h | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/libcxxabi/src/demangle/ItaniumDemangle.h b/libcxxabi/src/demangle/ItaniumDemangle.h
index 3df41b5f4d7d0..1b0cb72cd4712 100644
--- a/libcxxabi/src/demangle/ItaniumDemangle.h
+++ b/libcxxabi/src/demangle/ItaniumDemangle.h
@@ -5739,13 +5739,11 @@ struct FloatData<double>
template <>
struct FloatData<long double>
{
-#if defined(__mips__) && defined(__mips_n64) || defined(__aarch64__) || \
- defined(__wasm__) || defined(__riscv) || defined(__loongarch__) || \
- defined(__ve__)
+#if __LDBL_MANT_DIG__ == 113
static const size_t mangled_size = 32;
-#elif defined(__arm__) || defined(__mips__) || defined(__hexagon__)
+#elif __LDBL_MANT_DIG__ == 53
static const size_t mangled_size = 16;
-#else
+#else // __LDBL_MANT_DIG__ == 64
static const size_t mangled_size = 20; // May need to be adjusted to 16 or 24 on other platforms
#endif
// `-0x1.ffffffffffffffffffffffffffffp+16383` + 'L' + '\0' == 42 bytes.
>From 3d35fd88554a9c6dc7db913664f20055045eafb3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin at martin.st>
Date: Wed, 12 Mar 2025 23:39:48 +0200
Subject: [PATCH 3/3] [libcxxabi] [test] Avoid test failures with 64/128 bit
long doubles on x86
In libcxxabi/src/demangle/ItaniumDemangle.h, we have long double
demangling defined to 20 bytes for i386 and x86_64, based on
explicit arch ifdefs.
For i386 and x86_64 configurations that actually don't use
80 bit long doubles (such as Android), we don't have LDBL_FP80
set within the test, but the demangler is still capable of
demangling 80 bit long doubles, causing test failures like this.
.---command stdout------------
| Testing 29859 symbols.
| _ZN5test01hIfEEvRAcvjplstT_Le4001a000000000000000E_c should be invalid but is not
| Got: 0, void test0::h<float>(char (&) [(unsigned int)(sizeof (float) + 0x0.07ff98f7ep-1022L)])
`-----------------------------
.---command stderr------------
| Assertion failed: !passed && "demangle did not fail", file libcxxabi/test/test_demangle.pass.cpp, line 30338
`-----------------------------
---
libcxxabi/test/test_demangle.pass.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcxxabi/test/test_demangle.pass.cpp b/libcxxabi/test/test_demangle.pass.cpp
index e9c74f70a094b..f05db85da7a10 100644
--- a/libcxxabi/test/test_demangle.pass.cpp
+++ b/libcxxabi/test/test_demangle.pass.cpp
@@ -30301,7 +30301,7 @@ const char *invalid_cases[] = {
"_ZNSt16allocator_traitsISaIN4llvm3sys2fs18directory_iteratorEEE9constructIS3_IS3_EEEDTcl12_S_constructfp_fp0_spcl7forwardIT0_Efp1_EEERS4_PT_DpOS7_",
"3FooILdaaaaaaaaaaAAAAaaEE",
"3FooILdaaaaaaaaaaaaaaEE",
-#if !LDBL_FP80
+#if !LDBL_FP80 && !defined(__x86_64__) && !defined(__i386__)
"_ZN5test01hIfEEvRAcvjplstT_Le4001a000000000000000E_c",
#endif
// The following test cases were found by libFuzzer+ASAN
More information about the libcxx-commits
mailing list