[ubsan][mips] Revise r243384 to avoid special casing big-endian mips.
authorDaniel Sanders <daniel.sanders@imgtec.com>
Tue, 11 Aug 2015 18:40:02 +0000 (18:40 +0000)
committerDaniel Sanders <daniel.sanders@imgtec.com>
Tue, 11 Aug 2015 18:40:02 +0000 (18:40 +0000)
Account for the case when uptr is 32-bit instead of trying to fix this case
using the little endian path.

llvm-svn: 244646

compiler-rt/lib/ubsan/ubsan_value.cc

index 4ae385f..79dc4c8 100644 (file)
@@ -83,10 +83,11 @@ FloatMax Value::getFloatValue() const {
 #endif
       case 32: {
         float Value;
-#if defined(__BIG_ENDIAN__) && !defined(__mips__)
-       // 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);
+#if defined(__BIG_ENDIAN__)
+       // For big endian the float value is in the last 4 bytes.
+       // On some targets we may only have 4 bytes so we count backwards from
+       // the end of Val to account for both the 32-bit and 64-bit cases.
+       internal_memcpy(&Value, ((const char*)(&Val + 1)) - 4, 4);
 #else 
        internal_memcpy(&Value, &Val, 4);
 #endif