Skip to content

Commit a32d543

Browse files
Revert "[compiler-rt][ubsan] Add support for f16 (#129624)"
This reverts commit 23a30e6. The commit has broken some build bots.
1 parent b7f3104 commit a32d543

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

compiler-rt/lib/ubsan/ubsan_value.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,15 @@ FloatMax Value::getFloatValue() const {
120120
CHECK(getType().isFloatTy());
121121
if (isInlineFloat()) {
122122
switch (getType().getFloatBitWidth()) {
123-
case 16: {
124-
__fp16 Value;
125-
internal_memcpy(&Value, &Val, 2);
126-
return Value;
127-
}
123+
#if 0
124+
// FIXME: OpenCL / NEON 'half' type. LLVM can't lower the conversion
125+
// from '__fp16' to 'long double'.
126+
case 16: {
127+
__fp16 Value;
128+
internal_memcpy(&Value, &Val, 4);
129+
return Value;
130+
}
131+
#endif
128132
case 32: {
129133
float Value;
130134
#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
@@ -142,7 +146,7 @@ FloatMax Value::getFloatValue() const {
142146
internal_memcpy(&Value, &Val, 8);
143147
return Value;
144148
}
145-
}
149+
}
146150
} else {
147151
switch (getType().getFloatBitWidth()) {
148152
case 64: return *reinterpret_cast<double*>(Val);

compiler-rt/test/ubsan/TestCases/Float/cast-overflow.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// RUN: %run %t 5 2>&1 | FileCheck %s --check-prefix=CHECK-5
99
// RUN: %run %t 6 2>&1 | FileCheck %s --check-prefix=CHECK-6
1010
// RUN: %run %t 7 2>&1 | FileCheck %s --check-prefix=CHECK-7
11-
// RUN: %run %t 8 2>&1 | FileCheck %s --check-prefix=CHECK-8
1211

1312
// Issue #41838
1413
// XFAIL: sparc-target-arch && target={{.*solaris.*}}
@@ -133,17 +132,12 @@ int main(int argc, char **argv) {
133132
}
134133
case '5': {
135134
// CHECK-5: {{.*}}cast-overflow.cpp:[[@LINE+1]]:27: runtime error: {{.*}} is outside the range of representable values of type 'int'
136-
static int test_int = (__fp16)Inf;
137-
return 0;
138-
}
139-
case '6': {
140-
// CHECK-6: {{.*}}cast-overflow.cpp:[[@LINE+1]]:27: runtime error: {{.*}} is outside the range of representable values of type 'int'
141135
static int test_int = NaN;
142136
return 0;
143137
}
144138
// Integer -> floating point overflow.
145-
case '7': {
146-
// 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}}
139+
case '6': {
140+
// 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}}
147141
#if defined(__SIZEOF_INT128__) && !defined(_WIN32)
148142
static int test_int = (float)(FloatMaxAsUInt128 + 1);
149143
return 0;
@@ -154,9 +148,9 @@ int main(int argc, char **argv) {
154148
return 0;
155149
#endif
156150
}
157-
case '8': {
151+
case '7': {
158152
volatile long double ld = 300.0;
159-
// CHECK-8: {{.*}}cast-overflow.cpp:[[@LINE+1]]:14: runtime error: 300 is outside the range of representable values of type 'char'
153+
// CHECK-7: {{.*}}cast-overflow.cpp:[[@LINE+1]]:14: runtime error: 300 is outside the range of representable values of type 'char'
160154
char c = ld;
161155
// `c` is allowed to contain UNDEF, thus we should not use
162156
// its value as an exit code.

0 commit comments

Comments
 (0)