X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FSupport%2FHashing.cpp;h=c69efb7c3cc9880cd23b22400ac11163ff78d245;hb=ad591b341bf22bb4d3a7526d59d4ae6c414420ee;hp=89b84530afad150c4d2dcaae7caa0f5bb7258913;hpb=1a4b19ef9b870d8c914bcd5ceb520a64a9a2cc52;p=oota-llvm.git diff --git a/lib/Support/Hashing.cpp b/lib/Support/Hashing.cpp index 89b84530afa..c69efb7c3cc 100644 --- a/lib/Support/Hashing.cpp +++ b/lib/Support/Hashing.cpp @@ -1,4 +1,4 @@ -//===-- llvm/ADT/Hashing.cpp - Utilities for hashing ------------*- C++ -*-===// +//===-------------- lib/Support/Hashing.cpp -------------------------------===// // // The LLVM Compiler Infrastructure // @@ -6,41 +6,24 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// +// +// This file provides implementation bits for the LLVM common hashing +// infrastructure. Documentation and most of the other information is in the +// header file. +// +//===----------------------------------------------------------------------===// #include "llvm/ADT/Hashing.h" -namespace llvm { +using 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(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); - } -} +// Provide a definition and static initializer for the fixed seed. This +// initializer should always be zero to ensure its value can never appear to be +// non-zero, even during dynamic initialization. +size_t llvm::hashing::detail::fixed_seed_override = 0; +// Implement the function for forced setting of the fixed seed. +// FIXME: Use atomic operations here so that there is no data race. +void llvm::set_fixed_execution_hash_seed(size_t fixed_value) { + hashing::detail::fixed_seed_override = fixed_value; }