Skip to content

Commit

Permalink
Merging r243384:
Browse files Browse the repository at this point in the history
------------------------------------------------------------------------
r243384 | slthakur | 2015-07-28 06:51:51 +0100 (Tue, 28 Jul 2015) | 9 lines

[UBSan][MIPS] Fix cast-overflow tests for mips big endian

This fixes the bug https://llvm.org/bugs/show_bug.cgi?id=24152
The float value resides in the first 4 bytes of ValueHandle for both mips and mipsel.

Reviewers: dsanders, samsonov
Subscibers: rsmith, hans, mohit.bhakkad, jaydeep, llvm-commits
Differential: http://reviews.llvm.org/D11448

------------------------------------------------------------------------


git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/branches/release_37@245110 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
dsandersllvm committed Aug 14, 2015
1 parent f9ef0f8 commit fa183e2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/ubsan/ubsan_value.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ FloatMax Value::getFloatValue() const {
#endif
case 32: {
float Value;
#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);
#if defined(__BIG_ENDIAN__) && !defined(__mips__)
// For big endian the float value is in the highest addressed 4 bytes
// (the least significant bits) but we must also consider that we might
// have a 32-bit type.
internal_memcpy(&Value, ((const char*)&Val + 1) - 4, 4);
#else
internal_memcpy(&Value, &Val, 4);
#endif
Expand Down

0 comments on commit fa183e2

Please sign in to comment.