Skip to content

Conversation

ahatanak
Copy link
Collaborator

The builtins __fixunstfdi and __multc3 may be removed by the preprocessor depending on configuration flags. When this happens, the corresponding tests fail at link time due to missing definitions.

Disable these tests when the builtins are not available.

rdar://159705803
rdar://159705705

The builtins `__fixunstfdi` and `__multc3` may be removed by the
preprocessor depending on configuration flags. When this happens, the
corresponding tests fail at link time due to missing definitions.

Disable these tests when the builtins are not available.

rdar://159705803
rdar://159705705
@ahatanak
Copy link
Collaborator Author

Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we can get away with a simpler:

#if defined(CRT_HAS_TF_MODE)

and

#if defined(CRT_HAS_128BIT) && defined(CRT_HAS_F128)

and entirely drop the architecture checks. That simplifies the conditions and still serves the need. It also avoids this type of issue cropping up elsewhere.

Copy link

github-actions bot commented Sep 15, 2025

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff origin/main HEAD --extensions c -- compiler-rt/test/builtins/Unit/fixunstfdi_test.c compiler-rt/test/builtins/Unit/multc3_test.c

⚠️
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing origin/main to the base branch/commit you want to compare against.
⚠️

View the diff from clang-format here.
diff --git a/compiler-rt/test/builtins/Unit/fixunstfdi_test.c b/compiler-rt/test/builtins/Unit/fixunstfdi_test.c
index cfe1a87b0..75b72f92f 100644
--- a/compiler-rt/test/builtins/Unit/fixunstfdi_test.c
+++ b/compiler-rt/test/builtins/Unit/fixunstfdi_test.c
@@ -6,7 +6,7 @@
 
 #if defined(CRT_HAS_TF_MODE)
 
-#include "int_lib.h"
+#  include "int_lib.h"
 
 // Returns: convert a to a unsigned long long, rounding toward zero.
 //          Negative values all become zero.
@@ -36,77 +36,77 @@ char assumption_3[sizeof(long double)*CHAR_BIT == 128] = {0};
 int main()
 {
 #if defined(CRT_HAS_TF_MODE)
-    if (test__fixunstfdi(0.0, 0))
-        return 1;
-
-    if (test__fixunstfdi(0.5, 0))
-        return 1;
-    if (test__fixunstfdi(0.99, 0))
-        return 1;
-    if (test__fixunstfdi(1.0, 1))
-        return 1;
-    if (test__fixunstfdi(1.5, 1))
-        return 1;
-    if (test__fixunstfdi(1.99, 1))
-        return 1;
-    if (test__fixunstfdi(2.0, 2))
-        return 1;
-    if (test__fixunstfdi(2.01, 2))
-        return 1;
-    if (test__fixunstfdi(-0.5, 0))
-        return 1;
-    if (test__fixunstfdi(-0.99, 0))
-        return 1;
-    if (test__fixunstfdi(-1.0, 0))
-        return 1;
-    if (test__fixunstfdi(-1.5, 0))
-        return 1;
-    if (test__fixunstfdi(-1.99, 0))
-        return 1;
-    if (test__fixunstfdi(-2.0, 0))
-        return 1;
-    if (test__fixunstfdi(-2.01, 0))
-        return 1;
-
-    if (test__fixunstfdi(0x1.FFFFFEp+62, 0x7FFFFF8000000000LL))
-        return 1;
-    if (test__fixunstfdi(0x1.FFFFFCp+62, 0x7FFFFF0000000000LL))
-        return 1;
-
-    if (test__fixunstfdi(-0x1.FFFFFEp+62, 0))
-        return 1;
-    if (test__fixunstfdi(-0x1.FFFFFCp+62, 0))
-        return 1;
-
-    if (test__fixunstfdi(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFC00LL))
-        return 1;
-    if (test__fixunstfdi(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFFFFFFF800LL))
-        return 1;
-
-    if (test__fixunstfdi(-0x1.FFFFFFFFFFFFFp+62, 0))
-        return 1;
-    if (test__fixunstfdi(-0x1.FFFFFFFFFFFFEp+62, 0))
-        return 1;
-
-    if (test__fixunstfdi(0x1.FFFFFFFFFFFFFFFEp+63L, 0xFFFFFFFFFFFFFFFFLL))
-        return 1;
-    if (test__fixunstfdi(0x1.0000000000000002p+63L, 0x8000000000000001LL))
-        return 1;
-    if (test__fixunstfdi(0x1.0000000000000000p+63L, 0x8000000000000000LL))
-        return 1;
-    if (test__fixunstfdi(0x1.FFFFFFFFFFFFFFFCp+62L, 0x7FFFFFFFFFFFFFFFLL))
-        return 1;
-    if (test__fixunstfdi(0x1.FFFFFFFFFFFFFFF8p+62L, 0x7FFFFFFFFFFFFFFELL))
-        return 1;
-    if (test__fixunstfdi(0x1.p+64L, 0xFFFFFFFFFFFFFFFFLL))
-        return 1;
-
-    if (test__fixunstfdi(-0x1.0000000000000000p+63L, 0))
-        return 1;
-    if (test__fixunstfdi(-0x1.FFFFFFFFFFFFFFFCp+62L, 0))
-        return 1;
-    if (test__fixunstfdi(-0x1.FFFFFFFFFFFFFFF8p+62L, 0))
-        return 1;
+  if (test__fixunstfdi(0.0, 0))
+    return 1;
+
+  if (test__fixunstfdi(0.5, 0))
+    return 1;
+  if (test__fixunstfdi(0.99, 0))
+    return 1;
+  if (test__fixunstfdi(1.0, 1))
+    return 1;
+  if (test__fixunstfdi(1.5, 1))
+    return 1;
+  if (test__fixunstfdi(1.99, 1))
+    return 1;
+  if (test__fixunstfdi(2.0, 2))
+    return 1;
+  if (test__fixunstfdi(2.01, 2))
+    return 1;
+  if (test__fixunstfdi(-0.5, 0))
+    return 1;
+  if (test__fixunstfdi(-0.99, 0))
+    return 1;
+  if (test__fixunstfdi(-1.0, 0))
+    return 1;
+  if (test__fixunstfdi(-1.5, 0))
+    return 1;
+  if (test__fixunstfdi(-1.99, 0))
+    return 1;
+  if (test__fixunstfdi(-2.0, 0))
+    return 1;
+  if (test__fixunstfdi(-2.01, 0))
+    return 1;
+
+  if (test__fixunstfdi(0x1.FFFFFEp+62, 0x7FFFFF8000000000LL))
+    return 1;
+  if (test__fixunstfdi(0x1.FFFFFCp+62, 0x7FFFFF0000000000LL))
+    return 1;
+
+  if (test__fixunstfdi(-0x1.FFFFFEp+62, 0))
+    return 1;
+  if (test__fixunstfdi(-0x1.FFFFFCp+62, 0))
+    return 1;
+
+  if (test__fixunstfdi(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFC00LL))
+    return 1;
+  if (test__fixunstfdi(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFFFFFFF800LL))
+    return 1;
+
+  if (test__fixunstfdi(-0x1.FFFFFFFFFFFFFp+62, 0))
+    return 1;
+  if (test__fixunstfdi(-0x1.FFFFFFFFFFFFEp+62, 0))
+    return 1;
+
+  if (test__fixunstfdi(0x1.FFFFFFFFFFFFFFFEp+63L, 0xFFFFFFFFFFFFFFFFLL))
+    return 1;
+  if (test__fixunstfdi(0x1.0000000000000002p+63L, 0x8000000000000001LL))
+    return 1;
+  if (test__fixunstfdi(0x1.0000000000000000p+63L, 0x8000000000000000LL))
+    return 1;
+  if (test__fixunstfdi(0x1.FFFFFFFFFFFFFFFCp+62L, 0x7FFFFFFFFFFFFFFFLL))
+    return 1;
+  if (test__fixunstfdi(0x1.FFFFFFFFFFFFFFF8p+62L, 0x7FFFFFFFFFFFFFFELL))
+    return 1;
+  if (test__fixunstfdi(0x1.p+64L, 0xFFFFFFFFFFFFFFFFLL))
+    return 1;
+
+  if (test__fixunstfdi(-0x1.0000000000000000p+63L, 0))
+    return 1;
+  if (test__fixunstfdi(-0x1.FFFFFFFFFFFFFFFCp+62L, 0))
+    return 1;
+  if (test__fixunstfdi(-0x1.FFFFFFFFFFFFFFF8p+62L, 0))
+    return 1;
 
 #else
     printf("skipped\n");
diff --git a/compiler-rt/test/builtins/Unit/multc3_test.c b/compiler-rt/test/builtins/Unit/multc3_test.c
index 7ae4cb5b7..dedd7fb67 100644
--- a/compiler-rt/test/builtins/Unit/multc3_test.c
+++ b/compiler-rt/test/builtins/Unit/multc3_test.c
@@ -6,9 +6,9 @@
 
 #if defined(CRT_HAS_128BIT) && defined(CRT_HAS_F128)
 
-#include "int_lib.h"
-#include <math.h>
-#include <complex.h>
+#  include "int_lib.h"
+#  include <math.h>
+#  include <complex.h>
 
 // Returns: the product of a + ib and c + id
 
@@ -349,16 +349,14 @@ long double x[][2] =
 int main()
 {
 #if defined(CRT_HAS_128BIT) && defined(CRT_HAS_F128)
-    const unsigned N = sizeof(x) / sizeof(x[0]);
-    unsigned i, j;
-    for (i = 0; i < N; ++i)
-    {
-        for (j = 0; j < N; ++j)
-        {
-            if (test__multc3(x[i][0], x[i][1], x[j][0], x[j][1]))
-                return 1;
-        }
+  const unsigned N = sizeof(x) / sizeof(x[0]);
+  unsigned i, j;
+  for (i = 0; i < N; ++i) {
+    for (j = 0; j < N; ++j) {
+      if (test__multc3(x[i][0], x[i][1], x[j][0], x[j][1]))
+        return 1;
     }
+  }
 #else
     printf("skipped\n");
 #endif

@ahatanak
Copy link
Collaborator Author

ping

Copy link
Contributor

@jroelofs jroelofs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with clang-format fixes.

@ahatanak
Copy link
Collaborator Author

LGTM with clang-format fixes.

The formatting fix makes it harder to see what changes this PR is making to the test files. Also, for some reason clang-format is inserting spaces between # and include, which doesn't seem like an improvement.

I'll revert it back to a642476 and apply the formatting changes later if they are needed.

@ahatanak ahatanak merged commit e9e166e into llvm:main Sep 24, 2025
6 of 9 checks passed
@ahatanak ahatanak deleted the disable-unavailable-builtin-tests branch September 24, 2025 20:11
mstorsjo added a commit that referenced this pull request Sep 26, 2025
This reverts commit e9e166e,
and the follow-up fix 6567070.

These changes unlocked tests to run on architectures where they
didn't run before, showing up as test failures like in
https://lab.llvm.org/buildbot/#/builders/66/builds/19787.
@mstorsjo
Copy link
Member

FYI, for visibility here as well - as #160687 actually made these changes work as intended, it showed up as failed tests on x86_64, in https://lab.llvm.org/buildbot/#/builders/66/builds/19787 - so I reverted them both in f7e8350.

ahatanak added a commit to ahatanak/llvm-project that referenced this pull request Sep 29, 2025
The builtins `__fixunstfdi` and `__multc3` may be removed by the
preprocessor depending on configuration flags. When this happens, the
corresponding tests fail at link time due to missing definitions.

Disable these tests when the builtins are not available.

rdar://159705803
rdar://159705705
mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Oct 3, 2025
The builtins `__fixunstfdi` and `__multc3` may be removed by the
preprocessor depending on configuration flags. When this happens, the
corresponding tests fail at link time due to missing definitions.

Disable these tests when the builtins are not available.

rdar://159705803
rdar://159705705
mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Oct 3, 2025
…8664)"

This reverts commit e9e166e,
and the follow-up fix 6567070.

These changes unlocked tests to run on architectures where they
didn't run before, showing up as test failures like in
https://lab.llvm.org/buildbot/#/builders/66/builds/19787.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants