1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 11:42:57 +01:00

Make the hashing algorithm Endian neutral. This is a bit annoying, but

folks who know something about PPC tell me that the byte swap is crazy
fast and without this the bit mixture would actually be different. It
might not be worse, but I've not measured it and so I'd rather not trust
it. This way, the algorithm is identical on both endianness hosts. I'll
look into any performance issues etc stemming from this.

llvm-svn: 151892
This commit is contained in:
Chandler Carruth 2012-03-02 11:16:10 +00:00
parent 37925e436c
commit 53ca2f8c9e

View File

@ -47,6 +47,8 @@
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#include "llvm/Support/DataTypes.h" #include "llvm/Support/DataTypes.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/SwapByteOrder.h"
#include "llvm/Support/type_traits.h" #include "llvm/Support/type_traits.h"
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
@ -149,12 +151,16 @@ namespace detail {
inline uint64_t fetch64(const char *p) { inline uint64_t fetch64(const char *p) {
uint64_t result; uint64_t result;
memcpy(&result, p, sizeof(result)); memcpy(&result, p, sizeof(result));
if (sys::isBigEndianHost())
return sys::SwapByteOrder(result);
return result; return result;
} }
inline uint32_t fetch32(const char *p) { inline uint32_t fetch32(const char *p) {
uint32_t result; uint32_t result;
memcpy(&result, p, sizeof(result)); memcpy(&result, p, sizeof(result));
if (sys::isBigEndianHost())
return sys::SwapByteOrder(result);
return result; return result;
} }