[compiler-rt] r233813 - [PPC64]This activates UBSan for the power architecture.

Bill Seurer seurer at linux.vnet.ibm.com
Wed Apr 1 08:33:22 PDT 2015


Author: seurer
Date: Wed Apr  1 10:33:22 2015
New Revision: 233813

URL: http://llvm.org/viewvc/llvm-project?rev=233813&view=rev
Log:
[PPC64]This activates UBSan for the power architecture.

One test case is updated to allow for differences between power and other architectures in behavior when returning from main in certain instances

http://reviews.llvm.org/D8743


Modified:
    compiler-rt/trunk/cmake/config-ix.cmake
    compiler-rt/trunk/lib/ubsan/ubsan_platform.h
    compiler-rt/trunk/lib/ubsan/ubsan_value.cc
    compiler-rt/trunk/test/ubsan/TestCases/Float/cast-overflow.cpp

Modified: compiler-rt/trunk/cmake/config-ix.cmake
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/config-ix.cmake?rev=233813&r1=233812&r2=233813&view=diff
==============================================================================
--- compiler-rt/trunk/cmake/config-ix.cmake (original)
+++ compiler-rt/trunk/cmake/config-ix.cmake Wed Apr  1 10:33:22 2015
@@ -233,7 +233,8 @@ filter_available_targets(MSAN_SUPPORTED_
 filter_available_targets(PROFILE_SUPPORTED_ARCH x86_64 i386 i686 arm mips mips64
   mipsel mips64el aarch64 powerpc64 powerpc64le)
 filter_available_targets(TSAN_SUPPORTED_ARCH x86_64 mips64 mips64el)
-filter_available_targets(UBSAN_SUPPORTED_ARCH x86_64 i386 i686 arm aarch64 mips mipsel mips64 mips64el)
+filter_available_targets(UBSAN_SUPPORTED_ARCH x86_64 i386 i686 arm aarch64 mips
+  mipsel mips64 mips64el powerpc64 powerpc64le)
 
 if(ANDROID)
   set(OS_NAME "Android")

Modified: compiler-rt/trunk/lib/ubsan/ubsan_platform.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan/ubsan_platform.h?rev=233813&r1=233812&r2=233813&view=diff
==============================================================================
--- compiler-rt/trunk/lib/ubsan/ubsan_platform.h (original)
+++ compiler-rt/trunk/lib/ubsan/ubsan_platform.h Wed Apr  1 10:33:22 2015
@@ -16,7 +16,7 @@
 // Other platforms should be easy to add, and probably work as-is.
 #if (defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__)) && \
     (defined(__x86_64__) || defined(__i386__) || defined(__arm__) || \
-     defined(__aarch64__) || defined(__mips__))
+     defined(__aarch64__) || defined(__mips__) || defined(__powerpc64__))
 # define CAN_SANITIZE_UB 1
 #else
 # define CAN_SANITIZE_UB 0

Modified: compiler-rt/trunk/lib/ubsan/ubsan_value.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan/ubsan_value.cc?rev=233813&r1=233812&r2=233813&view=diff
==============================================================================
--- compiler-rt/trunk/lib/ubsan/ubsan_value.cc (original)
+++ compiler-rt/trunk/lib/ubsan/ubsan_value.cc Wed Apr  1 10:33:22 2015
@@ -83,7 +83,13 @@ FloatMax Value::getFloatValue() const {
 #endif
       case 32: {
         float Value;
-        internal_memcpy(&Value, &Val, 4);
+#if defined(__BIG_ENDIAN__)
+       // For big endian the float value is in the second 4 bytes
+       //  instead of the first 4 bytes.
+       internal_memcpy(&Value, ((const char*)&Val)+4, 4);
+#else 
+       internal_memcpy(&Value, &Val, 4);
+#endif
         return Value;
       }
       case 64: {

Modified: compiler-rt/trunk/test/ubsan/TestCases/Float/cast-overflow.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/TestCases/Float/cast-overflow.cpp?rev=233813&r1=233812&r2=233813&view=diff
==============================================================================
--- compiler-rt/trunk/test/ubsan/TestCases/Float/cast-overflow.cpp (original)
+++ compiler-rt/trunk/test/ubsan/TestCases/Float/cast-overflow.cpp Wed Apr  1 10:33:22 2015
@@ -82,11 +82,13 @@ int main(int argc, char **argv) {
     // FIXME: Produce a source location for these checks and test for it here.
 
     // Floating point -> integer overflow.
-  case '0':
+  case '0': {
     // Note that values between 0x7ffffe00 and 0x80000000 may or may not
     // successfully round-trip, depending on the rounding mode.
     // CHECK-0: runtime error: value 2.14748{{.*}} is outside the range of representable values of type 'int'
-    return MaxFloatRepresentableAsInt + 0x80;
+    static int test_int = MaxFloatRepresentableAsInt + 0x80;
+    return 0;
+    }
   case '1':
     // CHECK-1: runtime error: value -2.14748{{.*}} is outside the range of representable values of type 'int'
     return MinFloatRepresentableAsInt - 0x100;
@@ -96,26 +98,32 @@ int main(int argc, char **argv) {
     volatile unsigned u = (unsigned)f;
     return 0;
   }
-  case '3':
+  case '3': {
     // CHECK-3: runtime error: value 4.2949{{.*}} is outside the range of representable values of type 'unsigned int'
-    return (unsigned)(MaxFloatRepresentableAsUInt + 0x100);
+    static int test_int = (unsigned)(MaxFloatRepresentableAsUInt + 0x100);
+    return 0;
+  }
 
-  case '4':
+  case '4': {
     // CHECK-4: runtime error: value {{.*}} is outside the range of representable values of type 'int'
-    return Inf;
+    static int test_int = Inf;
+    return 0;
+  }
   case '5':
     // CHECK-5: runtime error: value {{.*}} is outside the range of representable values of type 'int'
     return NaN;
 
     // Integer -> floating point overflow.
-  case '6':
+  case '6': {
     // CHECK-6: {{runtime error: value 0xffffff00000000000000000000000001 is outside the range of representable values of type 'float'|__int128 not supported}}
 #ifdef __SIZEOF_INT128__
-    return (float)(FloatMaxAsUInt128 + 1);
+    static int test_int = (float)(FloatMaxAsUInt128 + 1);
+    return 0;
 #else
     puts("__int128 not supported");
     return 0;
 #endif
+  }
   // FIXME: The backend cannot lower __fp16 operations on x86 yet.
   //case '7':
   //  (__fp16)65504; // ok





More information about the llvm-commits mailing list