[compiler-rt] a32d543 - Revert "[compiler-rt][ubsan] Add support for f16 (#129624)"

Alexander Shaposhnikov via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 4 01:05:25 PST 2025


Author: Alexander Shaposhnikov
Date: 2025-03-04T09:04:46Z
New Revision: a32d5438ac50ef509af9e688f9cd93f1e98d929d

URL: https://github.com/llvm/llvm-project/commit/a32d5438ac50ef509af9e688f9cd93f1e98d929d
DIFF: https://github.com/llvm/llvm-project/commit/a32d5438ac50ef509af9e688f9cd93f1e98d929d.diff

LOG: Revert "[compiler-rt][ubsan] Add support for f16 (#129624)"

This reverts commit 23a30e68888e764b2f4d32e51d415b50fa5f5cac.
The commit has broken some build bots.

Added: 
    

Modified: 
    compiler-rt/lib/ubsan/ubsan_value.cpp
    compiler-rt/test/ubsan/TestCases/Float/cast-overflow.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/ubsan/ubsan_value.cpp b/compiler-rt/lib/ubsan/ubsan_value.cpp
index 2c2eaf3700511..6e88ebaf34d4b 100644
--- a/compiler-rt/lib/ubsan/ubsan_value.cpp
+++ b/compiler-rt/lib/ubsan/ubsan_value.cpp
@@ -120,11 +120,15 @@ FloatMax Value::getFloatValue() const {
   CHECK(getType().isFloatTy());
   if (isInlineFloat()) {
     switch (getType().getFloatBitWidth()) {
-    case 16: {
-      __fp16 Value;
-      internal_memcpy(&Value, &Val, 2);
-      return Value;
-    }
+#if 0
+      // FIXME: OpenCL / NEON 'half' type. LLVM can't lower the conversion
+      //        from '__fp16' to 'long double'.
+      case 16: {
+        __fp16 Value;
+        internal_memcpy(&Value, &Val, 4);
+        return Value;
+      }
+#endif
       case 32: {
         float Value;
 #if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
@@ -142,7 +146,7 @@ FloatMax Value::getFloatValue() const {
         internal_memcpy(&Value, &Val, 8);
         return Value;
       }
-      }
+    }
   } else {
     switch (getType().getFloatBitWidth()) {
     case 64: return *reinterpret_cast<double*>(Val);

diff  --git a/compiler-rt/test/ubsan/TestCases/Float/cast-overflow.cpp b/compiler-rt/test/ubsan/TestCases/Float/cast-overflow.cpp
index 306e24cc56858..8638bf69f749e 100644
--- a/compiler-rt/test/ubsan/TestCases/Float/cast-overflow.cpp
+++ b/compiler-rt/test/ubsan/TestCases/Float/cast-overflow.cpp
@@ -8,7 +8,6 @@
 // RUN: %run %t 5 2>&1 | FileCheck %s --check-prefix=CHECK-5
 // RUN: %run %t 6 2>&1 | FileCheck %s --check-prefix=CHECK-6
 // RUN: %run %t 7 2>&1 | FileCheck %s --check-prefix=CHECK-7
-// RUN: %run %t 8 2>&1 | FileCheck %s --check-prefix=CHECK-8
 
 // Issue #41838
 // XFAIL: sparc-target-arch && target={{.*solaris.*}}
@@ -133,17 +132,12 @@ int main(int argc, char **argv) {
   }
   case '5': {
     // CHECK-5: {{.*}}cast-overflow.cpp:[[@LINE+1]]:27: runtime error: {{.*}} is outside the range of representable values of type 'int'
-    static int test_int = (__fp16)Inf;
-    return 0;
-  }
-  case '6': {
-    // CHECK-6: {{.*}}cast-overflow.cpp:[[@LINE+1]]:27: runtime error: {{.*}} is outside the range of representable values of type 'int'
     static int test_int = NaN;
     return 0;
   }
   // Integer -> floating point overflow.
-  case '7': {
-    // CHECK-7: cast-overflow.cpp:[[@LINE+2]]:{{27: runtime error: 3.40282e\+38 is outside the range of representable values of type 'int'| __int128 not supported}}
+  case '6': {
+    // CHECK-6: cast-overflow.cpp:[[@LINE+2]]:{{27: runtime error: 3.40282e\+38 is outside the range of representable values of type 'int'| __int128 not supported}}
 #if defined(__SIZEOF_INT128__) && !defined(_WIN32)
     static int test_int = (float)(FloatMaxAsUInt128 + 1);
     return 0;
@@ -154,9 +148,9 @@ int main(int argc, char **argv) {
     return 0;
 #endif
   }
-  case '8': {
+  case '7': {
     volatile long double ld = 300.0;
-    // CHECK-8: {{.*}}cast-overflow.cpp:[[@LINE+1]]:14: runtime error: 300 is outside the range of representable values of type 'char'
+    // CHECK-7: {{.*}}cast-overflow.cpp:[[@LINE+1]]:14: runtime error: 300 is outside the range of representable values of type 'char'
     char c = ld;
     // `c` is allowed to contain UNDEF, thus we should not use
     // its value as an exit code.


        


More information about the llvm-commits mailing list