atrosinenko created this revision.
atrosinenko added reviewers: MaskRay, howard.hinnant, samsonov.
Herald added subscribers: Sanitizers, mgorny, dberris.
Herald added a project: Sanitizers.
atrosinenko requested review of this revision.
Herald added a subscriber: aheejin.

This patch introduces two "generic" pseudo targets to simplify testing
the changes to builtins library on a developer machine.

These targets

- ignore any target-specific subdirectories
- use the specified size of `long double` (this may simplify testing of 
QUAD_PRECISION libcall variants when working on a generic implementation on an 
X86 host)
- are intended *for testing only*
- may produce false positives (at least when non-default size of `long double` 
is selected)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87520

Files:
  compiler-rt/cmake/base-config-ix.cmake
  compiler-rt/cmake/builtin-config-ix.cmake
  compiler-rt/lib/builtins/CMakeLists.txt
  compiler-rt/test/builtins/Unit/addtf3_test.c
  compiler-rt/test/builtins/Unit/compiler_rt_logbl_test.c
  compiler-rt/test/builtins/Unit/divtc3_test.c
  compiler-rt/test/builtins/Unit/divxc3_test.c
  compiler-rt/test/builtins/Unit/subtf3_test.c

Index: compiler-rt/test/builtins/Unit/subtf3_test.c
===================================================================
--- compiler-rt/test/builtins/Unit/subtf3_test.c
+++ compiler-rt/test/builtins/Unit/subtf3_test.c
@@ -58,6 +58,7 @@
                      UINT64_C(0xa44a7bca780a166c)))
         return 1;
 
+#if !defined(GENERIC_TARGET)
 #if (defined(__arm__) || defined(__aarch64__)) && defined(__ARM_FP) || \
     defined(i386) || defined(__x86_64__)
     // Rounding mode tests on supported architectures
@@ -87,6 +88,7 @@
                      UINT64_C(0x70a3d70a3d70a3d7)))
         return 1;
 #endif
+#endif // !defined(GENERIC_TARGET)
 
 #else
     printf("skipped\n");
Index: compiler-rt/test/builtins/Unit/divxc3_test.c
===================================================================
--- compiler-rt/test/builtins/Unit/divxc3_test.c
+++ compiler-rt/test/builtins/Unit/divxc3_test.c
@@ -5,6 +5,10 @@
 // UNSUPPORTED: mips
 // REQUIRES: c99-complex
 
+// `long double` should have its default target-specific size
+// to be `classify()`ed properly.
+// XFAIL: generic_ldbl80-target-arch
+
 #if !_ARCH_PPC
 
 #include "int_lib.h"
Index: compiler-rt/test/builtins/Unit/divtc3_test.c
===================================================================
--- compiler-rt/test/builtins/Unit/divtc3_test.c
+++ compiler-rt/test/builtins/Unit/divtc3_test.c
@@ -6,6 +6,11 @@
 // Bug 42493
 // XFAIL: sparc-target-arch
 //
+
+// `long double` should have its default target-specific size
+// to be `classify()`ed properly.
+// XFAIL: generic_ldbl128-target-arch
+
 #include <stdio.h>
 
 #include "int_lib.h"
Index: compiler-rt/test/builtins/Unit/compiler_rt_logbl_test.c
===================================================================
--- compiler-rt/test/builtins/Unit/compiler_rt_logbl_test.c
+++ compiler-rt/test/builtins/Unit/compiler_rt_logbl_test.c
@@ -6,7 +6,11 @@
 #include "fp_lib.h"
 #include "int_lib.h"
 
-#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT)
+// GENERIC_TARGET may have non-default sizeof(long double), so it is useless
+// to compare __compiler_rt_logbl() against native logbl().
+
+#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) && \
+    !defined(GENERIC_TARGET)
 
 int test__compiler_rt_logbl(fp_t x) {
   fp_t crt_value = __compiler_rt_logbl(x);
@@ -38,7 +42,8 @@
 #endif
 
 int main() {
-#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT)
+#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) && \
+    !defined(GENERIC_TARGET)
   const unsigned N = sizeof(cases) / sizeof(cases[0]);
   unsigned i;
   for (i = 0; i < N; ++i) {
Index: compiler-rt/test/builtins/Unit/addtf3_test.c
===================================================================
--- compiler-rt/test/builtins/Unit/addtf3_test.c
+++ compiler-rt/test/builtins/Unit/addtf3_test.c
@@ -65,6 +65,7 @@
                      UINT64_C(0x61e58dd6c51eb77c)))
         return 1;
 
+#if !defined(GENERIC_TARGET)
 #if (defined(__arm__) || defined(__aarch64__)) && defined(__ARM_FP) || \
     defined(i386) || defined(__x86_64__)
     // Rounding mode tests on supported architectures
@@ -95,6 +96,7 @@
                      UINT64_C(0x70a3d70a3d70a3d7)))
         return 1;
 #endif
+#endif // !defined(GENERIC_TARGET)
 
 #else
     printf("skipped\n");
Index: compiler-rt/lib/builtins/CMakeLists.txt
===================================================================
--- compiler-rt/lib/builtins/CMakeLists.txt
+++ compiler-rt/lib/builtins/CMakeLists.txt
@@ -603,6 +603,16 @@
   ${GENERIC_TF_SOURCES}
   ${GENERIC_SOURCES})
 
+# For local testing only.
+set(generic_ldbl80_SOURCES
+  ${GENERIC_SOURCES}
+  ${x86_80_BIT_SOURCES}
+)
+set(generic_ldbl128_SOURCES
+  ${GENERIC_SOURCES}
+  ${GENERIC_TF_SOURCES}
+)
+
 add_custom_target(builtins)
 set_target_properties(builtins PROPERTIES FOLDER "Compiler-RT Misc")
 
Index: compiler-rt/cmake/builtin-config-ix.cmake
===================================================================
--- compiler-rt/cmake/builtin-config-ix.cmake
+++ compiler-rt/cmake/builtin-config-ix.cmake
@@ -39,6 +39,17 @@
 set(WASM64 wasm64)
 set(VE ve)
 
+# Build as many generic LibCall implementations as possible while not using any
+# target-specific implementations.
+# This is intended for local testing only to help catch bugs for generic LibCall
+# implementations that are normally shadowed by target-specific ones or
+# not built at all (such as float128-related code on some X86 targets) on a
+# developer machine.
+# NB: The test results may be not absolutely reliable (at least when using
+#     non-default size of `long double` due to using system-provided libm),
+#     so false positives are possible.
+set(GENERIC_FOR_TESTS generic_ldbl80 generic_ldbl128)
+
 if(APPLE)
   set(ARM64 arm64 arm64e)
   set(ARM32 armv7 armv7k armv7s)
@@ -49,7 +60,8 @@
   ${X86} ${X86_64} ${ARM32} ${ARM64}
   ${HEXAGON} ${MIPS32} ${MIPS64} ${PPC64}
   ${RISCV32} ${RISCV64} ${SPARC} ${SPARCV9}
-  ${WASM32} ${WASM64} ${VE})
+  ${WASM32} ${WASM64} ${VE}
+  ${GENERIC_FOR_TESTS})
 
 include(CompilerRTUtils)
 include(CompilerRTDarwinUtils)
Index: compiler-rt/cmake/base-config-ix.cmake
===================================================================
--- compiler-rt/cmake/base-config-ix.cmake
+++ compiler-rt/cmake/base-config-ix.cmake
@@ -239,6 +239,10 @@
       test_target_arch(wasm64 "" "--target=wasm64-unknown-unknown")
     elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "ve")
       test_target_arch(ve "__ve__" "--target=ve-unknown-none")
+    elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "generic_ldbl80_test")
+      test_target_arch(generic_ldbl80 "" "-mlong-double-80 -DGENERIC_TARGET")
+    elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "generic_ldbl128_test")
+      test_target_arch(generic_ldbl128 "" "-mlong-double-128 -DGENERIC_TARGET")
     endif()
     set(COMPILER_RT_OS_SUFFIX "")
   endif()
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D87520: [tests]... Anatoly Trosinenko via Phabricator via cfe-commits

Reply via email to