Skip to content

[libc][complex] implement different flavors of creal and cimag functions #113300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Nov 3, 2024

Conversation

Sh0g0-1758
Copy link
Member

@Sh0g0-1758 Sh0g0-1758 commented Oct 22, 2024

I have commented out the test for neg_zero(creal) because :

  1. real(neg_zero + 0.0i) equals zero.
  2. real(neg_zero - 0.0i) equals neg_zero.

I am not sure if this is the intended behaviour.

[EDIT]
I have updated tests for neg_zero (creal) to be :

    EXPECT_FP_EQ(func(CFPT(neg_zero - zero * 1.0i)), neg_zero);
    EXPECT_FP_EQ(func(CFPT(neg_zero + zero * 1.0i)), zero);

because all three [gcc, clang and GNU MPC] also give the same result.
https://godbolt.org/z/hxhcn6aof
and it seems that it is indeed the correct behaviour since Imaginary types are not supported yet, refer #113671

@Sh0g0-1758 Sh0g0-1758 requested a review from lntue October 22, 2024 11:35
@llvmbot llvmbot added the libc label Oct 22, 2024
@llvmbot
Copy link
Member

llvmbot commented Oct 22, 2024

@llvm/pr-subscribers-libc

Author: Shourya Goel (Sh0g0-1758)

Changes

Currently, the test for neg_zero is failing. I will need to look into that, Making this PR to get feedback about its general structure.


Patch is 23.70 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/113300.diff

25 Files Affected:

  • (modified) libc/config/linux/aarch64/entrypoints.txt (+11)
  • (modified) libc/config/linux/arm/entrypoints.txt (+5)
  • (modified) libc/config/linux/riscv/entrypoints.txt (+8)
  • (modified) libc/config/linux/x86_64/entrypoints.txt (+11)
  • (modified) libc/src/CMakeLists.txt (+1)
  • (added) libc/src/complex/CMakeLists.txt (+20)
  • (added) libc/src/complex/creal.h (+20)
  • (added) libc/src/complex/crealf.h (+20)
  • (added) libc/src/complex/crealf128.h (+27)
  • (added) libc/src/complex/crealf16.h (+27)
  • (added) libc/src/complex/creall.h (+20)
  • (added) libc/src/complex/generic/CMakeLists.txt (+49)
  • (added) libc/src/complex/generic/creal.cpp (+21)
  • (added) libc/src/complex/generic/crealf.cpp (+21)
  • (added) libc/src/complex/generic/crealf128.cpp (+25)
  • (added) libc/src/complex/generic/crealf16.cpp (+25)
  • (added) libc/src/complex/generic/creall.cpp (+21)
  • (modified) libc/test/src/CMakeLists.txt (+1)
  • (added) libc/test/src/complex/CMakeLists.txt (+61)
  • (added) libc/test/src/complex/CRealTest.h (+71)
  • (added) libc/test/src/complex/creal_test.cpp (+13)
  • (added) libc/test/src/complex/crealf128_test.cpp (+17)
  • (added) libc/test/src/complex/crealf16_test.cpp (+17)
  • (added) libc/test/src/complex/crealf_test.cpp (+13)
  • (added) libc/test/src/complex/creall_test.cpp (+13)
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index 71c6e874429fed..8fb60d252a99b3 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -356,6 +356,11 @@ if(LLVM_LIBC_INCLUDE_SCUDO)
 endif()
 
 set(TARGET_LIBM_ENTRYPOINTS
+    # complex.h entrypoints
+    libc.src.complex.creal
+    libc.src.complex.crealf
+    libc.src.complex.creall
+
     # fenv.h entrypoints
     libc.src.fenv.feclearexcept
     libc.src.fenv.fedisableexcept
@@ -603,6 +608,9 @@ set(TARGET_LIBM_ENTRYPOINTS
 
 if(LIBC_TYPES_HAS_FLOAT16)
   list(APPEND TARGET_LIBM_ENTRYPOINTS
+    # complex.h C23 _Complex _Float16 entrypoints
+    libc.src.complex.crealf16
+    
     # math.h C23 _Float16 entrypoints
     libc.src.math.canonicalizef16
     libc.src.math.ceilf16
@@ -703,6 +711,9 @@ endif()
 
 if(LIBC_TYPES_HAS_FLOAT128)
   list(APPEND TARGET_LIBM_ENTRYPOINTS
+    # complex.h C23 _Complex _Float128 entrypoints
+    libc.src.complex.crealf128
+
     # math.h C23 _Float128 entrypoints
     libc.src.math.canonicalizef128
     libc.src.math.ceilf128
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index 2ddb7aeefe48ec..9f98a89ee85b1a 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -197,6 +197,11 @@ if(LLVM_LIBC_INCLUDE_SCUDO)
 endif()
 
 set(TARGET_LIBM_ENTRYPOINTS
+    # complex.h entrypoints
+    libc.src.complex.creal
+    libc.src.complex.crealf
+    libc.src.complex.creall
+    
     # fenv.h entrypoints
     libc.src.fenv.feclearexcept
     libc.src.fenv.fedisableexcept
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index 5c09edf7cfb266..ad444ad54a028e 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -355,6 +355,11 @@ if(LLVM_LIBC_INCLUDE_SCUDO)
 endif()
 
 set(TARGET_LIBM_ENTRYPOINTS
+    # complex.h entrypoints
+    libc.src.complex.creal
+    libc.src.complex.crealf
+    libc.src.complex.creall
+
     # fenv.h entrypoints
     libc.src.fenv.feclearexcept
     libc.src.fenv.fedisableexcept
@@ -606,6 +611,9 @@ set(TARGET_LIBM_ENTRYPOINTS
 
 if(LIBC_TYPES_HAS_FLOAT128)
   list(APPEND TARGET_LIBM_ENTRYPOINTS
+    # complex.h C23 _Complex _Float128 entrypoints
+    libc.src.complex.crealf128
+    
     # math.h C23 _Float128 entrypoints
     libc.src.math.canonicalizef128
     libc.src.math.ceilf128
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 9bc63edf06f28c..536d9d328db7e1 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -355,6 +355,11 @@ if(LLVM_LIBC_INCLUDE_SCUDO)
 endif()
 
 set(TARGET_LIBM_ENTRYPOINTS
+    # complex.h entrypoints
+    libc.src.complex.creal
+    libc.src.complex.crealf
+    libc.src.complex.creall
+    
     # fenv.h entrypoints
     libc.src.fenv.feclearexcept
     libc.src.fenv.fedisableexcept
@@ -606,6 +611,9 @@ set(TARGET_LIBM_ENTRYPOINTS
 
 if(LIBC_TYPES_HAS_FLOAT16)
   list(APPEND TARGET_LIBM_ENTRYPOINTS
+    # complex.h C23 _Complex _Float16 entrypoints
+    libc.src.complex.crealf16
+
     # math.h C23 _Float16 entrypoints
     libc.src.math.canonicalizef16
     libc.src.math.ceilf16
@@ -708,6 +716,9 @@ endif()
 
 if(LIBC_TYPES_HAS_FLOAT128)
   list(APPEND TARGET_LIBM_ENTRYPOINTS
+    # complex.h C23 _Complex _Float128 entrypoints
+    libc.src.complex.crealf128
+    
     # math.h C23 _Float128 entrypoints
     libc.src.math.canonicalizef128
     libc.src.math.ceilf128
diff --git a/libc/src/CMakeLists.txt b/libc/src/CMakeLists.txt
index d554c12fb1ec89..02c193e635362e 100644
--- a/libc/src/CMakeLists.txt
+++ b/libc/src/CMakeLists.txt
@@ -1,5 +1,6 @@
 add_subdirectory(__support)
 
+add_subdirectory(complex)
 add_subdirectory(ctype)
 add_subdirectory(dlfcn)
 add_subdirectory(errno)
diff --git a/libc/src/complex/CMakeLists.txt b/libc/src/complex/CMakeLists.txt
new file mode 100644
index 00000000000000..92851b84b38eb6
--- /dev/null
+++ b/libc/src/complex/CMakeLists.txt
@@ -0,0 +1,20 @@
+add_subdirectory(generic)
+
+function(add_complex_entrypoint_object name)
+  get_fq_target_name("generic.${name}" fq_generic_target_name)
+  if(TARGET ${fq_generic_target_name})
+    add_entrypoint_object(
+      ${name}
+      ALIAS
+      DEPENDS
+        .generic.${name}
+    )
+    return()
+  endif()
+endfunction()
+
+add_complex_entrypoint_object(creal)
+add_complex_entrypoint_object(crealf)
+add_complex_entrypoint_object(creall)
+add_complex_entrypoint_object(crealf16)
+add_complex_entrypoint_object(crealf128)
diff --git a/libc/src/complex/creal.h b/libc/src/complex/creal.h
new file mode 100644
index 00000000000000..3ec5dd049b975d
--- /dev/null
+++ b/libc/src/complex/creal.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for creal -------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_COMPLEX_CREAL_H
+#define LLVM_LIBC_SRC_COMPLEX_CREAL_H
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+double creal(_Complex double x);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_COMPLEX_CREAL_H
diff --git a/libc/src/complex/crealf.h b/libc/src/complex/crealf.h
new file mode 100644
index 00000000000000..79dafc1c3758d5
--- /dev/null
+++ b/libc/src/complex/crealf.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for crealf ------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_COMPLEX_CREALF_H
+#define LLVM_LIBC_SRC_COMPLEX_CREALF_H
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+float crealf(_Complex float x);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_COMPLEX_CREALF_H
diff --git a/libc/src/complex/crealf128.h b/libc/src/complex/crealf128.h
new file mode 100644
index 00000000000000..4922ae78cb2386
--- /dev/null
+++ b/libc/src/complex/crealf128.h
@@ -0,0 +1,27 @@
+//===-- Implementation header for crealf128 ---------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/__support/macros/properties/complex_types.h"
+#include "src/__support/macros/properties/types.h"
+
+#if defined(LIBC_TYPES_HAS_CFLOAT128)
+
+#ifndef LLVM_LIBC_SRC_COMPLEX_CREALF128_H
+#define LLVM_LIBC_SRC_COMPLEX_CREALF128_H
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+float128 crealf128(cfloat128 x);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_COMPLEX_CREALF128_H
+
+#endif // LIBC_TYPES_HAS_CFLOAT128
diff --git a/libc/src/complex/crealf16.h b/libc/src/complex/crealf16.h
new file mode 100644
index 00000000000000..e6098a218d092d
--- /dev/null
+++ b/libc/src/complex/crealf16.h
@@ -0,0 +1,27 @@
+//===-- Implementation header for crealf16 ----------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/__support/macros/properties/complex_types.h"
+#include "src/__support/macros/properties/types.h"
+
+#if defined(LIBC_TYPES_HAS_CFLOAT16)
+
+#ifndef LLVM_LIBC_SRC_COMPLEX_CREALF16_H
+#define LLVM_LIBC_SRC_COMPLEX_CREALF16_H
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+float16 crealf16(cfloat16 x);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_COMPLEX_CREALF16_H
+
+#endif // LIBC_TYPES_HAS_CFLOAT16
diff --git a/libc/src/complex/creall.h b/libc/src/complex/creall.h
new file mode 100644
index 00000000000000..2a8245f63d6710
--- /dev/null
+++ b/libc/src/complex/creall.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for creall ------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_COMPLEX_CREALL_H
+#define LLVM_LIBC_SRC_COMPLEX_CREALL_H
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+long double creall(_Complex long double x);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_COMPLEX_CREALL_H
diff --git a/libc/src/complex/generic/CMakeLists.txt b/libc/src/complex/generic/CMakeLists.txt
new file mode 100644
index 00000000000000..f7b69e245cc205
--- /dev/null
+++ b/libc/src/complex/generic/CMakeLists.txt
@@ -0,0 +1,49 @@
+add_entrypoint_object(
+  creal
+  SRCS
+    creal.cpp
+  HDRS
+    ../creal.h
+  COMPILE_OPTIONS
+    -O3
+)
+
+add_entrypoint_object(
+  crealf
+  SRCS
+    crealf.cpp
+  HDRS
+    ../crealf.h
+  COMPILE_OPTIONS
+    -O3
+)
+
+add_entrypoint_object(
+  creall
+  SRCS
+    creall.cpp
+  HDRS
+    ../creall.h
+  COMPILE_OPTIONS
+    -O3
+)
+
+add_entrypoint_object(
+  crealf16
+  SRCS
+    crealf16.cpp
+  HDRS
+    ../crealf16.h
+  COMPILE_OPTIONS
+    -O3
+)
+
+add_entrypoint_object(
+  crealf128
+  SRCS
+    crealf128.cpp
+  HDRS
+    ../crealf128.h
+  COMPILE_OPTIONS
+    -O3
+)
diff --git a/libc/src/complex/generic/creal.cpp b/libc/src/complex/generic/creal.cpp
new file mode 100644
index 00000000000000..fbac499e939374
--- /dev/null
+++ b/libc/src/complex/generic/creal.cpp
@@ -0,0 +1,21 @@
+//===-- Implementation of creal function ----------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/complex/creal.h"
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(double, creal, (_Complex double x)) {
+  double *xCmplxPtr = reinterpret_cast<double *>(&x);
+  return xCmplxPtr[0];
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/complex/generic/crealf.cpp b/libc/src/complex/generic/crealf.cpp
new file mode 100644
index 00000000000000..f613e7fd566bce
--- /dev/null
+++ b/libc/src/complex/generic/crealf.cpp
@@ -0,0 +1,21 @@
+//===-- Implementation of crealf function ---------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/complex/crealf.h"
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float, crealf, (_Complex float x)) {
+  float *xCmplxPtr = reinterpret_cast<float *>(&x);
+  return xCmplxPtr[0];
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/complex/generic/crealf128.cpp b/libc/src/complex/generic/crealf128.cpp
new file mode 100644
index 00000000000000..df29102d259851
--- /dev/null
+++ b/libc/src/complex/generic/crealf128.cpp
@@ -0,0 +1,25 @@
+//===-- Implementation of crealf128 function ------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/complex/crealf128.h"
+#if defined(LIBC_TYPES_HAS_CFLOAT128)
+
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float128, crealf128, (cfloat128 x)) {
+  float128 *xCmplxPtr = reinterpret_cast<float128 *>(&x);
+  return xCmplxPtr[0];
+}
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_CFLOAT128
diff --git a/libc/src/complex/generic/crealf16.cpp b/libc/src/complex/generic/crealf16.cpp
new file mode 100644
index 00000000000000..fcb6181c988d74
--- /dev/null
+++ b/libc/src/complex/generic/crealf16.cpp
@@ -0,0 +1,25 @@
+//===-- Implementation of crealf16 function -------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/complex/crealf16.h"
+#if defined(LIBC_TYPES_HAS_CFLOAT16)
+
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float16, crealf16, (cfloat16 x)) {
+  float16 *xCmplxPtr = reinterpret_cast<float16 *>(&x);
+  return xCmplxPtr[0];
+}
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_CFLOAT16
diff --git a/libc/src/complex/generic/creall.cpp b/libc/src/complex/generic/creall.cpp
new file mode 100644
index 00000000000000..e961743ba87852
--- /dev/null
+++ b/libc/src/complex/generic/creall.cpp
@@ -0,0 +1,21 @@
+//===-- Implementation of creall function ---------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/complex/creall.h"
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(long double, creall, (_Complex long double x)) {
+  long double *xCmplxPtr = reinterpret_cast<long double *>(&x);
+  return xCmplxPtr[0];
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/test/src/CMakeLists.txt b/libc/test/src/CMakeLists.txt
index ddc6a5c7f6965f..e121555bd60a9f 100644
--- a/libc/test/src/CMakeLists.txt
+++ b/libc/test/src/CMakeLists.txt
@@ -47,6 +47,7 @@ function(add_fp_unittest name)
 endfunction(add_fp_unittest)
 
 add_subdirectory(__support)
+add_subdirectory(complex)
 add_subdirectory(ctype)
 add_subdirectory(errno)
 add_subdirectory(fenv)
diff --git a/libc/test/src/complex/CMakeLists.txt b/libc/test/src/complex/CMakeLists.txt
new file mode 100644
index 00000000000000..51d0d2a4278b42
--- /dev/null
+++ b/libc/test/src/complex/CMakeLists.txt
@@ -0,0 +1,61 @@
+add_custom_target(libc-complex-unittests)
+
+add_libc_test(
+  creal_test
+  SUITE
+    libc-complex-unittests
+  SRCS
+    creal_test.cpp
+  DEPENDS
+    libc.src.complex.creal
+  LINK_LIBRARIES
+      LibcFPTestHelpers
+)
+
+add_libc_test(
+  crealf_test
+  SUITE
+    libc-complex-unittests
+  SRCS
+    crealf_test.cpp
+  DEPENDS
+    libc.src.complex.crealf
+  LINK_LIBRARIES
+    LibcFPTestHelpers
+)
+
+add_libc_test(
+  creall_test
+  SUITE
+    libc-complex-unittests
+  SRCS
+    creall_test.cpp
+  DEPENDS
+    libc.src.complex.creall
+  LINK_LIBRARIES
+    LibcFPTestHelpers
+)
+
+add_libc_test(
+  crealf16_test
+  SUITE
+    libc-complex-unittests
+  SRCS
+    crealf16_test.cpp
+  DEPENDS
+    libc.src.complex.crealf16
+  LINK_LIBRARIES
+    LibcFPTestHelpers
+)
+
+add_libc_test(
+  crealf128_test
+  SUITE
+    libc-complex-unittests
+  SRCS
+    crealf128_test.cpp
+  DEPENDS
+    libc.src.complex.crealf128
+  LINK_LIBRARIES
+    LibcFPTestHelpers
+)
diff --git a/libc/test/src/complex/CRealTest.h b/libc/test/src/complex/CRealTest.h
new file mode 100644
index 00000000000000..684e7b580e6576
--- /dev/null
+++ b/libc/test/src/complex/CRealTest.h
@@ -0,0 +1,71 @@
+//===-- Utility class to test different flavors of creal --------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TEST_SRC_COMPLEX_CREALTEST_H
+#define LLVM_LIBC_TEST_SRC_COMPLEX_CREALTEST_H
+
+#include "test/UnitTest/FEnvSafeTest.h"
+#include "test/UnitTest/FPMatcher.h"
+#include "test/UnitTest/Test.h"
+
+#include "hdr/math_macros.h"
+
+template <typename CFPT, typename FPT>
+class CRealTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
+
+  DECLARE_SPECIAL_CONSTANTS(FPT)
+
+public:
+  typedef FPT (*CRealFunc)(CFPT);
+
+  void testSpecialNumbers(CRealFunc func) {
+    EXPECT_FP_EQ(func(CFPT(aNaN + 67.123i)), aNaN);
+    EXPECT_FP_EQ(func(CFPT(neg_aNaN + 78.319i)), neg_aNaN);
+    EXPECT_FP_EQ(func(CFPT(sNaN + 7813.131i)), sNaN);
+    EXPECT_FP_EQ(func(CFPT(neg_sNaN + 7824.152i)), neg_sNaN);
+    EXPECT_FP_EQ(func(CFPT(inf + 9024.2442i)), inf);
+    EXPECT_FP_EQ(func(CFPT(neg_inf + 8923.124i)), neg_inf);
+    EXPECT_FP_EQ(func(CFPT(min_normal + 782.124i)), min_normal);
+    EXPECT_FP_EQ(func(CFPT(max_normal + 2141.2352i)), max_normal);
+    EXPECT_FP_EQ(func(CFPT(neg_max_normal + 341.134i)), neg_max_normal);
+    EXPECT_FP_EQ(func(CFPT(min_denormal + 781.142i)), min_denormal);
+    EXPECT_FP_EQ(func(CFPT(neg_min_denormal + 781.134i)), neg_min_denormal);
+    EXPECT_FP_EQ(func(CFPT(max_denormal + 1241.112i)), max_denormal);
+    EXPECT_FP_EQ(func(CFPT(zero + 121.121i)), zero);
+    // EXPECT_FP_EQ(func(CFPT(neg_zero + 12341.1321i)), neg_zero);
+  }
+
+  void testRoundedNumbers(CRealFunc func) {
+    EXPECT_FP_EQ(func((CFPT)(4523.1413 + 12413.1414i)), (FPT)(4523.1413));
+    EXPECT_FP_EQ(func((CFPT)(-4523.1413 + 12413.1414i)), (FPT)(-4523.1413));
+    EXPECT_FP_EQ(func((CFPT)(4523.1413 - 12413.1414i)), (FPT)(4523.1413));
+    EXPECT_FP_EQ(func((CFPT)(-4523.1413 - 12413.1414i)), (FPT)(-4523.1413));
+
+    EXPECT_FP_EQ(func((CFPT)(3210.5678 + 9876.5432i)), (FPT)(3210.5678));
+    EXPECT_FP_EQ(func((CFPT)(-3210.5678 + 9876.5432i)), (FPT)(-3210.5678));
+    EXPECT_FP_EQ(func((CFPT)(3210.5678 - 9876.5432i)), (FPT)(3210.5678));
+    EXPECT_FP_EQ(func((CFPT)(-3210.5678 - 9876.5432i)), (FPT)(-3210.5678));
+
+    EXPECT_FP_EQ(func((CFPT)(1234.4321 + 4321.1234i)), (FPT)(1234.4321));
+    EXPECT_FP_EQ(func((CFPT)(-1234.4321 + 4321.1234i)), (FPT)(-1234.4321));
+    EXPECT_FP_EQ(func((CFPT)(1234.4321 - 4321.1234i)), (FPT)(1234.4321));
+    EXPECT_FP_EQ(func((CFPT)(-1234.4321 - 4321.1234i)), (FPT)(-1234.4321));
+
+    EXPECT_FP_EQ(func((CFPT)(6789.1234 + 8765.6789i)), (FPT)(6789.1234));
+    EXPECT_FP_EQ(func((CFPT)(-6789.1234 + 8765.6789i)), (FPT)(-6789.1234));
+    EXPECT_FP_EQ(func((CFPT)(6789.1234 - 8765.6789i)), (FPT)(6789.1234));
+    EXPECT_FP_EQ(func((CFPT)(-6789.1234 - 8765.6789i)), (FPT)(-6789.1234));
+  }
+};
+
+#define LIST_CREAL_TESTS(U, T, func)                                           \
+  using LlvmLibcCRealTest = CRealTest<U, T>;                                   \
+  TEST_F(LlvmLibcCRealTest, SpecialNumbers) { testSpecialNumbers(&func); }     \
+  TEST_F(LlvmLibcCRealTest, RoundedNumbers) { testRoundedNumbers(&func); }
+
+#endif // LLVM_LIBC_TEST_SRC_COMPLEX_CREALTEST_H
diff --git a/libc/test/src/comp...
[truncated]

@Sh0g0-1758 Sh0g0-1758 changed the title [libc][complex] implement different flavors of creal function [libc][complex] implement different flavors of creal and cimag functions Oct 25, 2024
@Sh0g0-1758 Sh0g0-1758 merged commit ffe04e0 into llvm:main Nov 3, 2024
8 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Nov 3, 2024

LLVM Buildbot has detected a new failure on builder libc-aarch64-ubuntu-dbg running on libc-aarch64-ubuntu while building libc at step 4 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/104/builds/9720

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py ...' (failure)
...
 Test Rounding To Nearest...
 Test Rounding Downward...
 Test Rounding Upward...
 Test Rounding Toward Zero...
[       OK ] LlvmLibcSinTest.InDoubleRange (1144 ms)
Ran 2 tests.  PASS: 2  FAIL: 0
[119/991] Building CXX object projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.crealf16_test.__unit__.__build__.dir/crealf16_test.cpp.o
[120/991] Building CXX object projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.cimagf128_test.__unit__.__build__.dir/cimagf128_test.cpp.o
[121/991] Linking CXX executable projects/libc/test/src/complex/libc.test.src.complex.crealf16_test.__unit__.__build__
[122/991] Running unit test libc.test.src.complex.crealf16_test.__unit__
FAILED: projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.crealf16_test.__unit__ 
cd /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/build/projects/libc/test/src/complex && /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/build/projects/libc/test/src/complex/libc.test.src.complex.crealf16_test.__unit__.__build__
No tests run.
[123/991] Linking CXX executable projects/libc/test/src/complex/libc.test.src.complex.cimagf16_test.__unit__.__build__
[124/991] Running unit test libc.test.src.math.tan_test.__unit__.__NO_ROUND_OPT
[==========] Running 2 tests from 1 test suite.
[ RUN      ] LlvmLibcTanTest.TrickyInputs
[       OK ] LlvmLibcTanTest.TrickyInputs (3 ms)
[ RUN      ] LlvmLibcTanTest.InDoubleRange
 Test Rounding To Nearest...
 Test Rounding Downward...
 Test Rounding Upward...
 Test Rounding Toward Zero...
[       OK ] LlvmLibcTanTest.InDoubleRange (1217 ms)
Ran 2 tests.  PASS: 2  FAIL: 0
[125/991] Building CXX object projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.creal_test.__unit__.__build__.dir/creal_test.cpp.o
[126/991] Running unit test libc.test.src.math.fdivl_test.__unit__
[==========] Running 2 tests from 1 test suite.
[ RUN      ] LlvmLibcDivTest.SubnormalRange
[       OK ] LlvmLibcDivTest.SubnormalRange (779 ms)
[ RUN      ] LlvmLibcDivTest.NormalRange
[       OK ] LlvmLibcDivTest.NormalRange (733 ms)
Ran 2 tests.  PASS: 2  FAIL: 0
[127/991] Linking CXX executable projects/libc/test/src/complex/libc.test.src.complex.cimagf128_test.__unit__.__build__
[128/991] Running unit test libc.test.src.math.cbrtf_test.__unit__
[==========] Running 2 tests from 1 test suite.
[ RUN      ] LlvmLibcCbrtfTest.InFloatRange
[       OK ] LlvmLibcCbrtfTest.InFloatRange (509 ms)
[ RUN      ] LlvmLibcCbrtfTest.SpecialValues
[       OK ] LlvmLibcCbrtfTest.SpecialValues (4 us)
Ran 2 tests.  PASS: 2  FAIL: 0
[129/991] Building CXX object projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.crealf_test.__unit__.__build__.dir/crealf_test.cpp.o
[130/991] Building CXX object projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.cimagf_test.__unit__.__build__.dir/cimagf_test.cpp.o
[131/991] Building CXX object projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.creall_test.__unit__.__build__.dir/creall_test.cpp.o
[132/991] Building CXX object projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.crealf128_test.__unit__.__build__.dir/crealf128_test.cpp.o
[133/991] Building CXX object projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.cimagl_test.__unit__.__build__.dir/cimagl_test.cpp.o
[134/991] Building CXX object projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.cimag_test.__unit__.__build__.dir/cimag_test.cpp.o
[135/991] Running unit test libc.test.src.math.log_test.__unit__
[==========] Running 4 tests from 1 test suite.
Step 7 (libc-unit-tests) failure: libc-unit-tests (failure)
...
 Test Rounding To Nearest...
 Test Rounding Downward...
 Test Rounding Upward...
 Test Rounding Toward Zero...
[       OK ] LlvmLibcSinTest.InDoubleRange (1144 ms)
Ran 2 tests.  PASS: 2  FAIL: 0
[119/991] Building CXX object projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.crealf16_test.__unit__.__build__.dir/crealf16_test.cpp.o
[120/991] Building CXX object projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.cimagf128_test.__unit__.__build__.dir/cimagf128_test.cpp.o
[121/991] Linking CXX executable projects/libc/test/src/complex/libc.test.src.complex.crealf16_test.__unit__.__build__
[122/991] Running unit test libc.test.src.complex.crealf16_test.__unit__
FAILED: projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.crealf16_test.__unit__ 
cd /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/build/projects/libc/test/src/complex && /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/build/projects/libc/test/src/complex/libc.test.src.complex.crealf16_test.__unit__.__build__
No tests run.
[123/991] Linking CXX executable projects/libc/test/src/complex/libc.test.src.complex.cimagf16_test.__unit__.__build__
[124/991] Running unit test libc.test.src.math.tan_test.__unit__.__NO_ROUND_OPT
[==========] Running 2 tests from 1 test suite.
[ RUN      ] LlvmLibcTanTest.TrickyInputs
[       OK ] LlvmLibcTanTest.TrickyInputs (3 ms)
[ RUN      ] LlvmLibcTanTest.InDoubleRange
 Test Rounding To Nearest...
 Test Rounding Downward...
 Test Rounding Upward...
 Test Rounding Toward Zero...
[       OK ] LlvmLibcTanTest.InDoubleRange (1217 ms)
Ran 2 tests.  PASS: 2  FAIL: 0
[125/991] Building CXX object projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.creal_test.__unit__.__build__.dir/creal_test.cpp.o
[126/991] Running unit test libc.test.src.math.fdivl_test.__unit__
[==========] Running 2 tests from 1 test suite.
[ RUN      ] LlvmLibcDivTest.SubnormalRange
[       OK ] LlvmLibcDivTest.SubnormalRange (779 ms)
[ RUN      ] LlvmLibcDivTest.NormalRange
[       OK ] LlvmLibcDivTest.NormalRange (733 ms)
Ran 2 tests.  PASS: 2  FAIL: 0
[127/991] Linking CXX executable projects/libc/test/src/complex/libc.test.src.complex.cimagf128_test.__unit__.__build__
[128/991] Running unit test libc.test.src.math.cbrtf_test.__unit__
[==========] Running 2 tests from 1 test suite.
[ RUN      ] LlvmLibcCbrtfTest.InFloatRange
[       OK ] LlvmLibcCbrtfTest.InFloatRange (509 ms)
[ RUN      ] LlvmLibcCbrtfTest.SpecialValues
[       OK ] LlvmLibcCbrtfTest.SpecialValues (4 us)
Ran 2 tests.  PASS: 2  FAIL: 0
[129/991] Building CXX object projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.crealf_test.__unit__.__build__.dir/crealf_test.cpp.o
[130/991] Building CXX object projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.cimagf_test.__unit__.__build__.dir/cimagf_test.cpp.o
[131/991] Building CXX object projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.creall_test.__unit__.__build__.dir/creall_test.cpp.o
[132/991] Building CXX object projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.crealf128_test.__unit__.__build__.dir/crealf128_test.cpp.o
[133/991] Building CXX object projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.cimagl_test.__unit__.__build__.dir/cimagl_test.cpp.o
[134/991] Building CXX object projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.cimag_test.__unit__.__build__.dir/cimag_test.cpp.o
[135/991] Running unit test libc.test.src.math.log_test.__unit__
[==========] Running 4 tests from 1 test suite.

@llvm-ci
Copy link
Collaborator

llvm-ci commented Nov 3, 2024

LLVM Buildbot has detected a new failure on builder libc-aarch64-ubuntu-fullbuild-dbg running on libc-aarch64-ubuntu while building libc at step 4 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/71/builds/9710

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py ...' (failure)
...
Ran 4 tests.  PASS: 4  FAIL: 0
[1417/3867] Running unit test libc.test.src.complex.crealf128_test.__unit__
[==========] Running 2 tests from 1 test suite.
[ RUN      ] LlvmLibcCRealTest.SpecialNumbers
[       OK ] LlvmLibcCRealTest.SpecialNumbers (7 us)
[ RUN      ] LlvmLibcCRealTest.RoundedNumbers
[       OK ] LlvmLibcCRealTest.RoundedNumbers (3 us)
Ran 2 tests.  PASS: 2  FAIL: 0
[1418/3867] Linking CXX executable projects/libc/test/src/__support/CPP/libc.test.src.__support.CPP.type_traits_test.__unit__.__build__
[1419/3867] Running unit test libc.test.src.complex.cimagf16_test.__unit__
FAILED: projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.cimagf16_test.__unit__ 
cd /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/build/projects/libc/test/src/complex && /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/build/projects/libc/test/src/complex/libc.test.src.complex.cimagf16_test.__unit__.__build__
No tests run.
[1420/3867] Running unit test libc.test.src.__support.CPP.type_traits_test.__unit__
[==========] Running 63 tests from 1 test suite.
[ RUN      ] LlvmLibcTypeTraitsTest.add_lvalue_reference [ParamType = __llvm_libc_19_0_0_git::cpp::Struct]
[       OK ] LlvmLibcTypeTraitsTest.add_lvalue_reference [ParamType = __llvm_libc_19_0_0_git::cpp::Struct] (2 us)
[ RUN      ] LlvmLibcTypeTraitsTest.add_lvalue_reference [ParamType = __llvm_libc_19_0_0_git::cpp::Union]
[       OK ] LlvmLibcTypeTraitsTest.add_lvalue_reference [ParamType = __llvm_libc_19_0_0_git::cpp::Union] (2 us)
[ RUN      ] LlvmLibcTypeTraitsTest.add_lvalue_reference [ParamType = __llvm_libc_19_0_0_git::cpp::Class]
[       OK ] LlvmLibcTypeTraitsTest.add_lvalue_reference [ParamType = __llvm_libc_19_0_0_git::cpp::Class] (1 us)
[ RUN      ] LlvmLibcTypeTraitsTest.add_lvalue_reference [ParamType = float]
[       OK ] LlvmLibcTypeTraitsTest.add_lvalue_reference [ParamType = float] (2 us)
[ RUN      ] LlvmLibcTypeTraitsTest.add_lvalue_reference [ParamType = int]
[       OK ] LlvmLibcTypeTraitsTest.add_lvalue_reference [ParamType = int] (1 us)
[ RUN      ] LlvmLibcTypeTraitsTest.add_lvalue_reference_void
[       OK ] LlvmLibcTypeTraitsTest.add_lvalue_reference_void (1 us)
[ RUN      ] LlvmLibcTypeTraitsTest.add_pointer [ParamType = __llvm_libc_19_0_0_git::cpp::Struct]
[       OK ] LlvmLibcTypeTraitsTest.add_pointer [ParamType = __llvm_libc_19_0_0_git::cpp::Struct] (1 us)
[ RUN      ] LlvmLibcTypeTraitsTest.add_pointer [ParamType = __llvm_libc_19_0_0_git::cpp::Union]
[       OK ] LlvmLibcTypeTraitsTest.add_pointer [ParamType = __llvm_libc_19_0_0_git::cpp::Union] (1 us)
[ RUN      ] LlvmLibcTypeTraitsTest.add_pointer [ParamType = __llvm_libc_19_0_0_git::cpp::Class]
[       OK ] LlvmLibcTypeTraitsTest.add_pointer [ParamType = __llvm_libc_19_0_0_git::cpp::Class] (2 us)
[ RUN      ] LlvmLibcTypeTraitsTest.add_pointer [ParamType = float]
[       OK ] LlvmLibcTypeTraitsTest.add_pointer [ParamType = float] (1 us)
[ RUN      ] LlvmLibcTypeTraitsTest.add_pointer [ParamType = int]
[       OK ] LlvmLibcTypeTraitsTest.add_pointer [ParamType = int] (1 us)
[ RUN      ] LlvmLibcTypeTraitsTest.add_pointer_void
[       OK ] LlvmLibcTypeTraitsTest.add_pointer_void (1 us)
[ RUN      ] LlvmLibcTypeTraitsTest.add_rvalue_reference [ParamType = __llvm_libc_19_0_0_git::cpp::Struct]
[       OK ] LlvmLibcTypeTraitsTest.add_rvalue_reference [ParamType = __llvm_libc_19_0_0_git::cpp::Struct] (1 us)
[ RUN      ] LlvmLibcTypeTraitsTest.add_rvalue_reference [ParamType = __llvm_libc_19_0_0_git::cpp::Union]
[       OK ] LlvmLibcTypeTraitsTest.add_rvalue_reference [ParamType = __llvm_libc_19_0_0_git::cpp::Union] (2 us)
[ RUN      ] LlvmLibcTypeTraitsTest.add_rvalue_reference [ParamType = __llvm_libc_19_0_0_git::cpp::Class]
[       OK ] LlvmLibcTypeTraitsTest.add_rvalue_reference [ParamType = __llvm_libc_19_0_0_git::cpp::Class] (1 us)
[ RUN      ] LlvmLibcTypeTraitsTest.add_rvalue_reference [ParamType = float]
[       OK ] LlvmLibcTypeTraitsTest.add_rvalue_reference [ParamType = float] (1 us)
[ RUN      ] LlvmLibcTypeTraitsTest.add_rvalue_reference [ParamType = int]
[       OK ] LlvmLibcTypeTraitsTest.add_rvalue_reference [ParamType = int] (1 us)
Step 8 (libc-unit-tests) failure: libc-unit-tests (failure)
...
Ran 4 tests.  PASS: 4  FAIL: 0
[1417/3867] Running unit test libc.test.src.complex.crealf128_test.__unit__
[==========] Running 2 tests from 1 test suite.
[ RUN      ] LlvmLibcCRealTest.SpecialNumbers
[       OK ] LlvmLibcCRealTest.SpecialNumbers (7 us)
[ RUN      ] LlvmLibcCRealTest.RoundedNumbers
[       OK ] LlvmLibcCRealTest.RoundedNumbers (3 us)
Ran 2 tests.  PASS: 2  FAIL: 0
[1418/3867] Linking CXX executable projects/libc/test/src/__support/CPP/libc.test.src.__support.CPP.type_traits_test.__unit__.__build__
[1419/3867] Running unit test libc.test.src.complex.cimagf16_test.__unit__
FAILED: projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.cimagf16_test.__unit__ 
cd /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/build/projects/libc/test/src/complex && /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/build/projects/libc/test/src/complex/libc.test.src.complex.cimagf16_test.__unit__.__build__
No tests run.
[1420/3867] Running unit test libc.test.src.__support.CPP.type_traits_test.__unit__
[==========] Running 63 tests from 1 test suite.
[ RUN      ] LlvmLibcTypeTraitsTest.add_lvalue_reference [ParamType = __llvm_libc_19_0_0_git::cpp::Struct]
[       OK ] LlvmLibcTypeTraitsTest.add_lvalue_reference [ParamType = __llvm_libc_19_0_0_git::cpp::Struct] (2 us)
[ RUN      ] LlvmLibcTypeTraitsTest.add_lvalue_reference [ParamType = __llvm_libc_19_0_0_git::cpp::Union]
[       OK ] LlvmLibcTypeTraitsTest.add_lvalue_reference [ParamType = __llvm_libc_19_0_0_git::cpp::Union] (2 us)
[ RUN      ] LlvmLibcTypeTraitsTest.add_lvalue_reference [ParamType = __llvm_libc_19_0_0_git::cpp::Class]
[       OK ] LlvmLibcTypeTraitsTest.add_lvalue_reference [ParamType = __llvm_libc_19_0_0_git::cpp::Class] (1 us)
[ RUN      ] LlvmLibcTypeTraitsTest.add_lvalue_reference [ParamType = float]
[       OK ] LlvmLibcTypeTraitsTest.add_lvalue_reference [ParamType = float] (2 us)
[ RUN      ] LlvmLibcTypeTraitsTest.add_lvalue_reference [ParamType = int]
[       OK ] LlvmLibcTypeTraitsTest.add_lvalue_reference [ParamType = int] (1 us)
[ RUN      ] LlvmLibcTypeTraitsTest.add_lvalue_reference_void
[       OK ] LlvmLibcTypeTraitsTest.add_lvalue_reference_void (1 us)
[ RUN      ] LlvmLibcTypeTraitsTest.add_pointer [ParamType = __llvm_libc_19_0_0_git::cpp::Struct]
[       OK ] LlvmLibcTypeTraitsTest.add_pointer [ParamType = __llvm_libc_19_0_0_git::cpp::Struct] (1 us)
[ RUN      ] LlvmLibcTypeTraitsTest.add_pointer [ParamType = __llvm_libc_19_0_0_git::cpp::Union]
[       OK ] LlvmLibcTypeTraitsTest.add_pointer [ParamType = __llvm_libc_19_0_0_git::cpp::Union] (1 us)
[ RUN      ] LlvmLibcTypeTraitsTest.add_pointer [ParamType = __llvm_libc_19_0_0_git::cpp::Class]
[       OK ] LlvmLibcTypeTraitsTest.add_pointer [ParamType = __llvm_libc_19_0_0_git::cpp::Class] (2 us)
[ RUN      ] LlvmLibcTypeTraitsTest.add_pointer [ParamType = float]
[       OK ] LlvmLibcTypeTraitsTest.add_pointer [ParamType = float] (1 us)
[ RUN      ] LlvmLibcTypeTraitsTest.add_pointer [ParamType = int]
[       OK ] LlvmLibcTypeTraitsTest.add_pointer [ParamType = int] (1 us)
[ RUN      ] LlvmLibcTypeTraitsTest.add_pointer_void
[       OK ] LlvmLibcTypeTraitsTest.add_pointer_void (1 us)
[ RUN      ] LlvmLibcTypeTraitsTest.add_rvalue_reference [ParamType = __llvm_libc_19_0_0_git::cpp::Struct]
[       OK ] LlvmLibcTypeTraitsTest.add_rvalue_reference [ParamType = __llvm_libc_19_0_0_git::cpp::Struct] (1 us)
[ RUN      ] LlvmLibcTypeTraitsTest.add_rvalue_reference [ParamType = __llvm_libc_19_0_0_git::cpp::Union]
[       OK ] LlvmLibcTypeTraitsTest.add_rvalue_reference [ParamType = __llvm_libc_19_0_0_git::cpp::Union] (2 us)
[ RUN      ] LlvmLibcTypeTraitsTest.add_rvalue_reference [ParamType = __llvm_libc_19_0_0_git::cpp::Class]
[       OK ] LlvmLibcTypeTraitsTest.add_rvalue_reference [ParamType = __llvm_libc_19_0_0_git::cpp::Class] (1 us)
[ RUN      ] LlvmLibcTypeTraitsTest.add_rvalue_reference [ParamType = float]
[       OK ] LlvmLibcTypeTraitsTest.add_rvalue_reference [ParamType = float] (1 us)
[ RUN      ] LlvmLibcTypeTraitsTest.add_rvalue_reference [ParamType = int]
[       OK ] LlvmLibcTypeTraitsTest.add_rvalue_reference [ParamType = int] (1 us)

@llvm-ci
Copy link
Collaborator

llvm-ci commented Nov 3, 2024

LLVM Buildbot has detected a new failure on builder libc-x86_64-debian-gcc-fullbuild-dbg running on libc-x86_64-debian-fullbuild while building libc at step 4 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/131/builds/9594

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py ...' (failure)
...
[       OK ] LlvmLibcTableTest.Insertion (128 us)
Ran 4 tests.  PASS: 4  FAIL: 0
[1724/4848] Building CXX object projects/libc/test/src/ctype/CMakeFiles/libc.test.src.ctype.isblank_test.__unit__.__build__.dir/isblank_test.cpp.o
[1725/4848] Linking CXX executable projects/libc/test/src/complex/libc.test.src.complex.crealf128_test.__unit__.__build__
[1726/4848] Building CXX object projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.creal_test.__unit__.__build__.dir/creal_test.cpp.o
[1727/4848] Building CXX object projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.cimagf_test.__unit__.__build__.dir/cimagf_test.cpp.o
[1728/4848] Building CXX object projects/libc/test/src/ctype/CMakeFiles/libc.test.src.ctype.iscntrl_test.__unit__.__build__.dir/iscntrl_test.cpp.o
[1729/4848] Building CXX object projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.crealf_test.__unit__.__build__.dir/crealf_test.cpp.o
[1730/4848] Linking CXX executable projects/libc/test/src/ctype/libc.test.src.ctype.isascii_test.__unit__.__build__
[1731/4848] Running unit test libc.test.src.complex.crealf128_test.__unit__
FAILED: projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.crealf128_test.__unit__ /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/build/projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.crealf128_test.__unit__ 
cd /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/build/projects/libc/test/src/complex && /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/build/projects/libc/test/src/complex/libc.test.src.complex.crealf128_test.__unit__.__build__
No tests run.
[1732/4848] Running unit test libc.test.src.ctype.isascii_test.__unit__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcIsAscii.DefaultLocale
[       OK ] LlvmLibcIsAscii.DefaultLocale (34 us)
Ran 1 tests.  PASS: 1  FAIL: 0
[1733/4848] Building CXX object projects/libc/test/src/ctype/CMakeFiles/libc.test.src.ctype.isprint_test.__unit__.__build__.dir/isprint_test.cpp.o
[1734/4848] Building CXX object projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.creall_test.__unit__.__build__.dir/creall_test.cpp.o
[1735/4848] Linking CXX executable projects/libc/test/src/ctype/libc.test.src.ctype.isdigit_test.__unit__.__build__
[1736/4848] Linking CXX executable projects/libc/test/src/complex/libc.test.src.complex.cimagf128_test.__unit__.__build__
[1737/4848] Linking CXX executable projects/libc/test/src/ctype/libc.test.src.ctype.isalpha_test.__unit__.__build__
[1738/4848] Building CXX object projects/libc/test/src/ctype/CMakeFiles/libc.test.src.ctype.isgraph_test.__unit__.__build__.dir/isgraph_test.cpp.o
[1739/4848] Linking CXX executable projects/libc/test/src/ctype/libc.test.src.ctype.isblank_test.__unit__.__build__
[1740/4848] Linking CXX executable projects/libc/test/src/ctype/libc.test.src.ctype.iscntrl_test.__unit__.__build__
[1741/4848] Linking CXX executable projects/libc/test/src/complex/libc.test.src.complex.cimagf_test.__unit__.__build__
[1742/4848] Linking CXX executable projects/libc/test/src/complex/libc.test.src.complex.creal_test.__unit__.__build__
[1743/4848] Linking CXX executable projects/libc/test/src/complex/libc.test.src.complex.crealf_test.__unit__.__build__
[1744/4848] Building CXX object projects/libc/test/src/ctype/CMakeFiles/libc.test.src.ctype.islower_test.__unit__.__build__.dir/islower_test.cpp.o
[1745/4848] Building CXX object projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.cimagl_test.__unit__.__build__.dir/cimagl_test.cpp.o
[1746/4848] Building CXX object projects/libc/test/src/ctype/CMakeFiles/libc.test.src.ctype.ispunct_test.__unit__.__build__.dir/ispunct_test.cpp.o
[1747/4848] Building CXX object projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.cimag_test.__unit__.__build__.dir/cimag_test.cpp.o
[1748/4848] Building CXX object projects/libc/test/src/ctype/CMakeFiles/libc.test.src.ctype.isxdigit_test.__unit__.__build__.dir/isxdigit_test.cpp.o
[1749/4848] Running unit test libc.test.src.__support.threads.linux.raw_mutex_test.__unit__
[==========] Running 3 tests from 1 test suite.
[ RUN      ] LlvmLibcSupportThreadsRawMutexTest.SmokeTest
[       OK ] LlvmLibcSupportThreadsRawMutexTest.SmokeTest (3 us)
[ RUN      ] LlvmLibcSupportThreadsRawMutexTest.Timeout
[       OK ] LlvmLibcSupportThreadsRawMutexTest.Timeout (315 us)
[ RUN      ] LlvmLibcSupportThreadsRawMutexTest.PSharedLock
[       OK ] LlvmLibcSupportThreadsRawMutexTest.PSharedLock (9 ms)
Ran 3 tests.  PASS: 3  FAIL: 0
[1750/4848] Building CXX object projects/libc/test/src/ctype/CMakeFiles/libc.test.src.ctype.isspace_test.__unit__.__build__.dir/isspace_test.cpp.o
[1751/4848] Building CXX object projects/libc/test/src/__support/FPUtil/CMakeFiles/libc.test.src.__support.FPUtil.fpbits_test.__unit__.__build__.dir/fpbits_test.cpp.o
[1752/4848] Building CXX object projects/libc/test/src/ctype/CMakeFiles/libc.test.src.ctype.toupper_test.__unit__.__build__.dir/toupper_test.cpp.o
[1753/4848] Building CXX object projects/libc/test/src/ctype/CMakeFiles/libc.test.src.ctype.isupper_test.__unit__.__build__.dir/isupper_test.cpp.o
[1754/4848] Building CXX object projects/libc/test/src/fenv/CMakeFiles/libc.test.src.fenv.feclearexcept_test.__build__.dir/feclearexcept_test.cpp.o
[1755/4848] Building CXX object projects/libc/test/src/errno/CMakeFiles/libc.test.src.errno.errno_test.__build__.dir/errno_test.cpp.o
Step 8 (libc-unit-tests) failure: libc-unit-tests (failure)
...
[       OK ] LlvmLibcTableTest.Insertion (128 us)
Ran 4 tests.  PASS: 4  FAIL: 0
[1724/4848] Building CXX object projects/libc/test/src/ctype/CMakeFiles/libc.test.src.ctype.isblank_test.__unit__.__build__.dir/isblank_test.cpp.o
[1725/4848] Linking CXX executable projects/libc/test/src/complex/libc.test.src.complex.crealf128_test.__unit__.__build__
[1726/4848] Building CXX object projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.creal_test.__unit__.__build__.dir/creal_test.cpp.o
[1727/4848] Building CXX object projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.cimagf_test.__unit__.__build__.dir/cimagf_test.cpp.o
[1728/4848] Building CXX object projects/libc/test/src/ctype/CMakeFiles/libc.test.src.ctype.iscntrl_test.__unit__.__build__.dir/iscntrl_test.cpp.o
[1729/4848] Building CXX object projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.crealf_test.__unit__.__build__.dir/crealf_test.cpp.o
[1730/4848] Linking CXX executable projects/libc/test/src/ctype/libc.test.src.ctype.isascii_test.__unit__.__build__
[1731/4848] Running unit test libc.test.src.complex.crealf128_test.__unit__
FAILED: projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.crealf128_test.__unit__ /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/build/projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.crealf128_test.__unit__ 
cd /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/build/projects/libc/test/src/complex && /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/build/projects/libc/test/src/complex/libc.test.src.complex.crealf128_test.__unit__.__build__
No tests run.
[1732/4848] Running unit test libc.test.src.ctype.isascii_test.__unit__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcIsAscii.DefaultLocale
[       OK ] LlvmLibcIsAscii.DefaultLocale (34 us)
Ran 1 tests.  PASS: 1  FAIL: 0
[1733/4848] Building CXX object projects/libc/test/src/ctype/CMakeFiles/libc.test.src.ctype.isprint_test.__unit__.__build__.dir/isprint_test.cpp.o
[1734/4848] Building CXX object projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.creall_test.__unit__.__build__.dir/creall_test.cpp.o
[1735/4848] Linking CXX executable projects/libc/test/src/ctype/libc.test.src.ctype.isdigit_test.__unit__.__build__
[1736/4848] Linking CXX executable projects/libc/test/src/complex/libc.test.src.complex.cimagf128_test.__unit__.__build__
[1737/4848] Linking CXX executable projects/libc/test/src/ctype/libc.test.src.ctype.isalpha_test.__unit__.__build__
[1738/4848] Building CXX object projects/libc/test/src/ctype/CMakeFiles/libc.test.src.ctype.isgraph_test.__unit__.__build__.dir/isgraph_test.cpp.o
[1739/4848] Linking CXX executable projects/libc/test/src/ctype/libc.test.src.ctype.isblank_test.__unit__.__build__
[1740/4848] Linking CXX executable projects/libc/test/src/ctype/libc.test.src.ctype.iscntrl_test.__unit__.__build__
[1741/4848] Linking CXX executable projects/libc/test/src/complex/libc.test.src.complex.cimagf_test.__unit__.__build__
[1742/4848] Linking CXX executable projects/libc/test/src/complex/libc.test.src.complex.creal_test.__unit__.__build__
[1743/4848] Linking CXX executable projects/libc/test/src/complex/libc.test.src.complex.crealf_test.__unit__.__build__
[1744/4848] Building CXX object projects/libc/test/src/ctype/CMakeFiles/libc.test.src.ctype.islower_test.__unit__.__build__.dir/islower_test.cpp.o
[1745/4848] Building CXX object projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.cimagl_test.__unit__.__build__.dir/cimagl_test.cpp.o
[1746/4848] Building CXX object projects/libc/test/src/ctype/CMakeFiles/libc.test.src.ctype.ispunct_test.__unit__.__build__.dir/ispunct_test.cpp.o
[1747/4848] Building CXX object projects/libc/test/src/complex/CMakeFiles/libc.test.src.complex.cimag_test.__unit__.__build__.dir/cimag_test.cpp.o
[1748/4848] Building CXX object projects/libc/test/src/ctype/CMakeFiles/libc.test.src.ctype.isxdigit_test.__unit__.__build__.dir/isxdigit_test.cpp.o
[1749/4848] Running unit test libc.test.src.__support.threads.linux.raw_mutex_test.__unit__
[==========] Running 3 tests from 1 test suite.
[ RUN      ] LlvmLibcSupportThreadsRawMutexTest.SmokeTest
[       OK ] LlvmLibcSupportThreadsRawMutexTest.SmokeTest (3 us)
[ RUN      ] LlvmLibcSupportThreadsRawMutexTest.Timeout
[       OK ] LlvmLibcSupportThreadsRawMutexTest.Timeout (315 us)
[ RUN      ] LlvmLibcSupportThreadsRawMutexTest.PSharedLock
[       OK ] LlvmLibcSupportThreadsRawMutexTest.PSharedLock (9 ms)
Ran 3 tests.  PASS: 3  FAIL: 0
[1750/4848] Building CXX object projects/libc/test/src/ctype/CMakeFiles/libc.test.src.ctype.isspace_test.__unit__.__build__.dir/isspace_test.cpp.o
[1751/4848] Building CXX object projects/libc/test/src/__support/FPUtil/CMakeFiles/libc.test.src.__support.FPUtil.fpbits_test.__unit__.__build__.dir/fpbits_test.cpp.o
[1752/4848] Building CXX object projects/libc/test/src/ctype/CMakeFiles/libc.test.src.ctype.toupper_test.__unit__.__build__.dir/toupper_test.cpp.o
[1753/4848] Building CXX object projects/libc/test/src/ctype/CMakeFiles/libc.test.src.ctype.isupper_test.__unit__.__build__.dir/isupper_test.cpp.o
[1754/4848] Building CXX object projects/libc/test/src/fenv/CMakeFiles/libc.test.src.fenv.feclearexcept_test.__build__.dir/feclearexcept_test.cpp.o
[1755/4848] Building CXX object projects/libc/test/src/errno/CMakeFiles/libc.test.src.errno.errno_test.__build__.dir/errno_test.cpp.o

smallp-o-p pushed a commit to smallp-o-p/llvm-project that referenced this pull request Nov 3, 2024
…nctions (llvm#113300)

I have commented out the test for `neg_zero`(creal) because : 

1. real(neg_zero + 0.0i) equals zero. 
2. real(neg_zero - 0.0i) equals neg_zero.

I am not sure if this is the intended behaviour. 

[EDIT]
I have updated tests for `neg_zero` (creal) to be : 

```
    EXPECT_FP_EQ(func(CFPT(neg_zero - zero * 1.0i)), neg_zero);
    EXPECT_FP_EQ(func(CFPT(neg_zero + zero * 1.0i)), zero);
```

because all three [gcc, clang and GNU MPC] also give the same result. 
https://godbolt.org/z/hxhcn6aof
and it seems that it is indeed the correct behaviour since Imaginary
types are not supported yet, refer llvm#113671
Sh0g0-1758 added a commit that referenced this pull request Nov 3, 2024
NoumanAmir657 pushed a commit to NoumanAmir657/llvm-project that referenced this pull request Nov 4, 2024
…nctions (llvm#113300)

I have commented out the test for `neg_zero`(creal) because : 

1. real(neg_zero + 0.0i) equals zero. 
2. real(neg_zero - 0.0i) equals neg_zero.

I am not sure if this is the intended behaviour. 

[EDIT]
I have updated tests for `neg_zero` (creal) to be : 

```
    EXPECT_FP_EQ(func(CFPT(neg_zero - zero * 1.0i)), neg_zero);
    EXPECT_FP_EQ(func(CFPT(neg_zero + zero * 1.0i)), zero);
```

because all three [gcc, clang and GNU MPC] also give the same result. 
https://godbolt.org/z/hxhcn6aof
and it seems that it is indeed the correct behaviour since Imaginary
types are not supported yet, refer llvm#113671
NoumanAmir657 pushed a commit to NoumanAmir657/llvm-project that referenced this pull request Nov 4, 2024
PhilippRados pushed a commit to PhilippRados/llvm-project that referenced this pull request Nov 6, 2024
…nctions (llvm#113300)

I have commented out the test for `neg_zero`(creal) because : 

1. real(neg_zero + 0.0i) equals zero. 
2. real(neg_zero - 0.0i) equals neg_zero.

I am not sure if this is the intended behaviour. 

[EDIT]
I have updated tests for `neg_zero` (creal) to be : 

```
    EXPECT_FP_EQ(func(CFPT(neg_zero - zero * 1.0i)), neg_zero);
    EXPECT_FP_EQ(func(CFPT(neg_zero + zero * 1.0i)), zero);
```

because all three [gcc, clang and GNU MPC] also give the same result. 
https://godbolt.org/z/hxhcn6aof
and it seems that it is indeed the correct behaviour since Imaginary
types are not supported yet, refer llvm#113671
PhilippRados pushed a commit to PhilippRados/llvm-project that referenced this pull request Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants