aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJay Foad <jay.foad@gmail.com>2012-02-23 09:16:04 +0000
committerJay Foad <jay.foad@gmail.com>2012-02-23 09:16:04 +0000
commit6592eacf9006d046e8bc4999600e2973a3b56eac (patch)
treea8f2920a38d80052600147c30fb16f49e3307f1d /lib
parent9d91c5d31c6758124559c0916d852295f47a2bec (diff)
downloadexternal_llvm-6592eacf9006d046e8bc4999600e2973a3b56eac.zip
external_llvm-6592eacf9006d046e8bc4999600e2973a3b56eac.tar.gz
external_llvm-6592eacf9006d046e8bc4999600e2973a3b56eac.tar.bz2
The implementation of GeneralHash::addBits broke C++ aliasing rules; fix
it with memcpy. This also fixes a problem on big-endian hosts, where addUnaligned would return different results depending on the alignment of the data. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151247 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Support/Hashing.cpp46
1 files changed, 0 insertions, 46 deletions
diff --git a/lib/Support/Hashing.cpp b/lib/Support/Hashing.cpp
deleted file mode 100644
index 21fcdd7..0000000
--- a/lib/Support/Hashing.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-//===-- llvm/ADT/Hashing.cpp - Utilities for hashing ------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/ADT/Hashing.h"
-
-namespace llvm {
-
-// Add a possibly unaligned sequence of bytes.
-void GeneralHash::addUnaligned(const uint8_t *I, const uint8_t *E) {
- ptrdiff_t Length = E - I;
- if ((uintptr_t(I) & 3) == 0) {
- while (Length > 3) {
- mix(*reinterpret_cast<const uint32_t *>(I));
- I += 4;
- Length -= 4;
- }
- } else {
- while (Length > 3) {
- mix(
- uint32_t(I[0]) +
- (uint32_t(I[1]) << 8) +
- (uint32_t(I[2]) << 16) +
- (uint32_t(I[3]) << 24));
- I += 4;
- Length -= 4;
- }
- }
-
- if (Length & 3) {
- uint32_t Data = 0;
- switch (Length & 3) {
- case 3: Data |= uint32_t(I[2]) << 16; // fall through
- case 2: Data |= uint32_t(I[1]) << 8; // fall through
- case 1: Data |= uint32_t(I[0]); break;
- }
- mix(Data);
- }
-}
-
-}