Revert r230655, "gold-plugin: "Upgrade" debug info and handle its warnings."
[oota-llvm.git] / lib / Support / Hashing.cpp
index 89b84530afad150c4d2dcaae7caa0f5bb7258913..c69efb7c3cc9880cd23b22400ac11163ff78d245 100644 (file)
@@ -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<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);
-  }
-}
+// 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;
 }