[llvm-commits] [compiler-rt] r168955 - in /compiler-rt/trunk/lib/ubsan/lit_tests: Float/cast-overflow.cpp Integer/add-overflow.cpp Integer/div-zero.cpp Integer/sub-overflow.cpp Integer/uadd-overflow.cpp Integer/usub-overflow.cpp
Richard Smith
richard-llvm at metafoo.co.uk
Thu Nov 29 15:03:58 PST 2012
Author: rsmith
Date: Thu Nov 29 17:03:58 2012
New Revision: 168955
URL: http://llvm.org/viewvc/llvm-project?rev=168955&view=rev
Log:
ubsan: Disable __int128 tests if the host Clang does not support it. These
tests will still fail if compiler-rt was built with a compiler without __int128
support, but the host compiler has __int128 support.
Modified:
compiler-rt/trunk/lib/ubsan/lit_tests/Float/cast-overflow.cpp
compiler-rt/trunk/lib/ubsan/lit_tests/Integer/add-overflow.cpp
compiler-rt/trunk/lib/ubsan/lit_tests/Integer/div-zero.cpp
compiler-rt/trunk/lib/ubsan/lit_tests/Integer/sub-overflow.cpp
compiler-rt/trunk/lib/ubsan/lit_tests/Integer/uadd-overflow.cpp
compiler-rt/trunk/lib/ubsan/lit_tests/Integer/usub-overflow.cpp
Modified: compiler-rt/trunk/lib/ubsan/lit_tests/Float/cast-overflow.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan/lit_tests/Float/cast-overflow.cpp?rev=168955&r1=168954&r2=168955&view=diff
==============================================================================
--- compiler-rt/trunk/lib/ubsan/lit_tests/Float/cast-overflow.cpp (original)
+++ compiler-rt/trunk/lib/ubsan/lit_tests/Float/cast-overflow.cpp Thu Nov 29 17:03:58 2012
@@ -14,6 +14,7 @@
// This test assumes float and double are IEEE-754 single- and double-precision.
#include <stdint.h>
+#include <stdio.h>
#include <string.h>
float Inf;
@@ -30,8 +31,10 @@
float MaxFloatRepresentableAsUInt = 0xffffff00u;
(unsigned int)MaxFloatRepresentableAsUInt; // ok
+#ifdef __SIZEOF_INT128__
unsigned __int128 FloatMaxAsUInt128 = -((unsigned __int128)1 << 104);
(void)(float)FloatMaxAsUInt128; // ok
+#endif
// Build a '+Inf'.
char InfVal[] = { 0x00, 0x00, 0x80, 0x7f };
@@ -71,8 +74,13 @@
// Integer -> floating point overflow.
case '6':
- // CHECK-6: fatal error: value 0xffffff00000000000000000000000001 is outside the range of representable values of type 'float'
+ // CHECK-6: {{fatal error: value 0xffffff00000000000000000000000001 is outside the range of representable values of type 'float'|__int128 not supported}}
+#ifdef __SIZEOF_INT128__
return (float)(FloatMaxAsUInt128 + 1);
+#else
+ puts("__int128 not supported");
+ return 0;
+#endif
// FIXME: The backend cannot lower __fp16 operations on x86 yet.
//case '7':
// (__fp16)65504; // ok
Modified: compiler-rt/trunk/lib/ubsan/lit_tests/Integer/add-overflow.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan/lit_tests/Integer/add-overflow.cpp?rev=168955&r1=168954&r2=168955&view=diff
==============================================================================
--- compiler-rt/trunk/lib/ubsan/lit_tests/Integer/add-overflow.cpp (original)
+++ compiler-rt/trunk/lib/ubsan/lit_tests/Integer/add-overflow.cpp Thu Nov 29 17:03:58 2012
@@ -3,6 +3,7 @@
// RUN: %clang -DADD_I128 -fsanitize=signed-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=ADD_I128
#include <stdint.h>
+#include <stdio.h>
int main() {
// These promote to 'int'.
@@ -12,7 +13,7 @@
#ifdef ADD_I32
int32_t k = 0x12345678;
k += 0x789abcde;
- // CHECK-ADD_I32: add-overflow.cpp:14:5: fatal error: signed integer overflow: 305419896 + 2023406814 cannot be represented in type 'int32_t' (aka 'int')
+ // CHECK-ADD_I32: add-overflow.cpp:[[@LINE-1]]:5: fatal error: signed integer overflow: 305419896 + 2023406814 cannot be represented in type 'int32_t' (aka 'int')
#endif
#ifdef ADD_I64
@@ -21,7 +22,11 @@
#endif
#ifdef ADD_I128
+# ifdef __SIZEOF_INT128__
(void)((__int128_t(1) << 126) + (__int128_t(1) << 126));
- // CHECK-ADD_I128: 0x40000000000000000000000000000000 + 0x40000000000000000000000000000000 cannot be represented in type '__int128'
+# else
+ puts("__int128 not supported");
+# endif
+ // CHECK-ADD_I128: {{0x40000000000000000000000000000000 \+ 0x40000000000000000000000000000000 cannot be represented in type '__int128'|__int128 not supported}}
#endif
}
Modified: compiler-rt/trunk/lib/ubsan/lit_tests/Integer/div-zero.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan/lit_tests/Integer/div-zero.cpp?rev=168955&r1=168954&r2=168955&view=diff
==============================================================================
--- compiler-rt/trunk/lib/ubsan/lit_tests/Integer/div-zero.cpp (original)
+++ compiler-rt/trunk/lib/ubsan/lit_tests/Integer/div-zero.cpp Thu Nov 29 17:03:58 2012
@@ -1,9 +1,15 @@
// RUN: %clang -fsanitize=integer-divide-by-zero -DDIVIDEND=0 %s -o %t && %t 2>&1 | FileCheck %s
// RUN: %clang -fsanitize=integer-divide-by-zero -DDIVIDEND=1U %s -o %t && %t 2>&1 | FileCheck %s
// RUN: %clang -fsanitize=float-divide-by-zero -DDIVIDEND=1.5 %s -o %t && %t 2>&1 | FileCheck %s
-// RUN: %clang -fsanitize=integer-divide-by-zero -DDIVIDEND='__int128(123)' %s -o %t && %t 2>&1 | FileCheck %s
+// RUN: %clang -fsanitize=integer-divide-by-zero -DDIVIDEND='intmax(123)' %s -o %t && %t 2>&1 | FileCheck %s
+
+#ifdef __SIZEOF_INT128__
+typedef __int128 intmax;
+#else
+typedef long long intmax;
+#endif
int main() {
- // CHECK: div-zero.cpp:8:12: fatal error: division by zero
+ // CHECK: div-zero.cpp:[[@LINE+1]]:12: fatal error: division by zero
DIVIDEND / 0;
}
Modified: compiler-rt/trunk/lib/ubsan/lit_tests/Integer/sub-overflow.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan/lit_tests/Integer/sub-overflow.cpp?rev=168955&r1=168954&r2=168955&view=diff
==============================================================================
--- compiler-rt/trunk/lib/ubsan/lit_tests/Integer/sub-overflow.cpp (original)
+++ compiler-rt/trunk/lib/ubsan/lit_tests/Integer/sub-overflow.cpp Thu Nov 29 17:03:58 2012
@@ -3,6 +3,7 @@
// RUN: %clang -DSUB_I128 -fsanitize=signed-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=SUB_I128
#include <stdint.h>
+#include <stdio.h>
int main() {
// These promote to 'int'.
@@ -11,7 +12,7 @@
#ifdef SUB_I32
(void)(int32_t(-2) - int32_t(0x7fffffff));
- // CHECK-SUB_I32: sub-overflow.cpp:13:22: fatal error: signed integer overflow: -2 - 2147483647 cannot be represented in type 'int'
+ // CHECK-SUB_I32: sub-overflow.cpp:[[@LINE-1]]:22: fatal error: signed integer overflow: -2 - 2147483647 cannot be represented in type 'int'
#endif
#ifdef SUB_I64
@@ -20,7 +21,11 @@
#endif
#ifdef SUB_I128
+# ifdef __SIZEOF_INT128__
(void)(-(__int128_t(1) << 126) - (__int128_t(1) << 126) - 1);
- // CHECK-SUB_I128: 0x80000000000000000000000000000000 - 1 cannot be represented in type '__int128'
+# else
+ puts("__int128 not supported");
+# endif
+ // CHECK-SUB_I128: {{0x80000000000000000000000000000000 - 1 cannot be represented in type '__int128'|__int128 not supported}}
#endif
}
Modified: compiler-rt/trunk/lib/ubsan/lit_tests/Integer/uadd-overflow.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan/lit_tests/Integer/uadd-overflow.cpp?rev=168955&r1=168954&r2=168955&view=diff
==============================================================================
--- compiler-rt/trunk/lib/ubsan/lit_tests/Integer/uadd-overflow.cpp (original)
+++ compiler-rt/trunk/lib/ubsan/lit_tests/Integer/uadd-overflow.cpp Thu Nov 29 17:03:58 2012
@@ -3,6 +3,7 @@
// RUN: %clang -DADD_I128 -fsanitize=unsigned-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=ADD_I128
#include <stdint.h>
+#include <stdio.h>
int main() {
// These promote to 'int'.
@@ -12,7 +13,7 @@
#ifdef ADD_I32
uint32_t k = 0x87654321;
k += 0xedcba987;
- // CHECK-ADD_I32: uadd-overflow.cpp:14:5: fatal error: unsigned integer overflow: 2271560481 + 3989547399 cannot be represented in type 'uint32_t' (aka 'unsigned int')
+ // CHECK-ADD_I32: uadd-overflow.cpp:[[@LINE-1]]:5: fatal error: unsigned integer overflow: 2271560481 + 3989547399 cannot be represented in type 'uint32_t' (aka 'unsigned int')
#endif
#ifdef ADD_I64
@@ -21,7 +22,11 @@
#endif
#ifdef ADD_I128
+# ifdef __SIZEOF_INT128__
(void)((__uint128_t(1) << 127) + (__uint128_t(1) << 127));
- // CHECK-ADD_I128: 0x80000000000000000000000000000000 + 0x80000000000000000000000000000000 cannot be represented in type 'unsigned __int128'
+# else
+ puts("__int128 not supported");
+# endif
+ // CHECK-ADD_I128: {{0x80000000000000000000000000000000 \+ 0x80000000000000000000000000000000 cannot be represented in type 'unsigned __int128'|__int128 not supported}}
#endif
}
Modified: compiler-rt/trunk/lib/ubsan/lit_tests/Integer/usub-overflow.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan/lit_tests/Integer/usub-overflow.cpp?rev=168955&r1=168954&r2=168955&view=diff
==============================================================================
--- compiler-rt/trunk/lib/ubsan/lit_tests/Integer/usub-overflow.cpp (original)
+++ compiler-rt/trunk/lib/ubsan/lit_tests/Integer/usub-overflow.cpp Thu Nov 29 17:03:58 2012
@@ -3,6 +3,7 @@
// RUN: %clang -DSUB_I128 -fsanitize=unsigned-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=SUB_I128
#include <stdint.h>
+#include <stdio.h>
int main() {
// These promote to 'int'.
@@ -11,7 +12,7 @@
#ifdef SUB_I32
(void)(uint32_t(1) - uint32_t(2));
- // CHECK-SUB_I32: usub-overflow.cpp:13:22: fatal error: unsigned integer overflow: 1 - 2 cannot be represented in type 'unsigned int'
+ // CHECK-SUB_I32: usub-overflow.cpp:[[@LINE-1]]:22: fatal error: unsigned integer overflow: 1 - 2 cannot be represented in type 'unsigned int'
#endif
#ifdef SUB_I64
@@ -20,7 +21,11 @@
#endif
#ifdef SUB_I128
+# ifdef __SIZEOF_INT128__
(void)((__uint128_t(1) << 126) - (__uint128_t(1) << 127));
- // CHECK-SUB_I128: 0x40000000000000000000000000000000 - 0x80000000000000000000000000000000 cannot be represented in type 'unsigned __int128'
+# else
+ puts("__int128 not supported\n");
+# endif
+ // CHECK-SUB_I128: {{0x40000000000000000000000000000000 - 0x80000000000000000000000000000000 cannot be represented in type 'unsigned __int128'|__int128 not supported}}
#endif
}
More information about the llvm-commits
mailing list