[test-suite] r331240 - [ubsan] Make the C++ code here not cast floating point values outside
Chandler Carruth via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 30 18:12:18 PDT 2018
Author: chandlerc
Date: Mon Apr 30 18:12:18 2018
New Revision: 331240
URL: http://llvm.org/viewvc/llvm-project?rev=331240&view=rev
Log:
[ubsan] Make the C++ code here not cast floating point values outside
the range of an integer type to that integer type.
Instead, change the random value function to cast to the destination
type first and do the devision by 8 afterward. When the destination is
floating point this should be roughly equivalent, but when it is an
integer type it will end up truncating stuff down rather than ending up
outside the range.
Differential Revision: https://reviews.llvm.org/D46295
Modified:
test-suite/trunk/Bitcode/Regression/vector_widen/driver.cpp
test-suite/trunk/Bitcode/simd_ops/simd_ops.cpp
Modified: test-suite/trunk/Bitcode/Regression/vector_widen/driver.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/Bitcode/Regression/vector_widen/driver.cpp?rev=331240&r1=331239&r2=331240&view=diff
==============================================================================
--- test-suite/trunk/Bitcode/Regression/vector_widen/driver.cpp (original)
+++ test-suite/trunk/Bitcode/Regression/vector_widen/driver.cpp Mon Apr 30 18:12:18 2018
@@ -2,7 +2,7 @@
template<typename T>
T rand_value() {
- return (T)(rand() * 0.125) - 100;
+ return (T)((T)rand() / 8) - 100;
}
template<typename T>
Modified: test-suite/trunk/Bitcode/simd_ops/simd_ops.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/Bitcode/simd_ops/simd_ops.cpp?rev=331240&r1=331239&r2=331240&view=diff
==============================================================================
--- test-suite/trunk/Bitcode/simd_ops/simd_ops.cpp (original)
+++ test-suite/trunk/Bitcode/simd_ops/simd_ops.cpp Mon Apr 30 18:12:18 2018
@@ -24,7 +24,7 @@ int allocate_aligned(void **mem, size_t
template<typename T>
T rand_value() {
- return (T)(rand() * 0.125) - 100;
+ return (T)((T)rand() / 8) - 100;
}
// Even on android, we want errors to stdout
More information about the llvm-commits
mailing list