Hashing.cpp revision 53930f6d0870b65553f663a2094ca39c3f4bdc98
153930f6d0870b65553f663a2094ca39c3f4bdc98Chandler Carruth//===-------------- lib/Support/Hashing.cpp -------------------------------===//
253930f6d0870b65553f663a2094ca39c3f4bdc98Chandler Carruth//
353930f6d0870b65553f663a2094ca39c3f4bdc98Chandler Carruth//                     The LLVM Compiler Infrastructure
453930f6d0870b65553f663a2094ca39c3f4bdc98Chandler Carruth//
553930f6d0870b65553f663a2094ca39c3f4bdc98Chandler Carruth// This file is distributed under the University of Illinois Open Source
653930f6d0870b65553f663a2094ca39c3f4bdc98Chandler Carruth// License. See LICENSE.TXT for details.
753930f6d0870b65553f663a2094ca39c3f4bdc98Chandler Carruth//
853930f6d0870b65553f663a2094ca39c3f4bdc98Chandler Carruth//===----------------------------------------------------------------------===//
953930f6d0870b65553f663a2094ca39c3f4bdc98Chandler Carruth//
1053930f6d0870b65553f663a2094ca39c3f4bdc98Chandler Carruth// This file provides implementation bits for the LLVM common hashing
1153930f6d0870b65553f663a2094ca39c3f4bdc98Chandler Carruth// infrastructure. Documentation and most of the other information is in the
1253930f6d0870b65553f663a2094ca39c3f4bdc98Chandler Carruth// header file.
1353930f6d0870b65553f663a2094ca39c3f4bdc98Chandler Carruth//
1453930f6d0870b65553f663a2094ca39c3f4bdc98Chandler Carruth//===----------------------------------------------------------------------===//
1553930f6d0870b65553f663a2094ca39c3f4bdc98Chandler Carruth
1653930f6d0870b65553f663a2094ca39c3f4bdc98Chandler Carruth#include "llvm/ADT/Hashing.h"
1753930f6d0870b65553f663a2094ca39c3f4bdc98Chandler Carruth
1853930f6d0870b65553f663a2094ca39c3f4bdc98Chandler Carruthusing namespace llvm;
1953930f6d0870b65553f663a2094ca39c3f4bdc98Chandler Carruth
2053930f6d0870b65553f663a2094ca39c3f4bdc98Chandler Carruth// Provide a definition and static initializer for the fixed seed. This
2153930f6d0870b65553f663a2094ca39c3f4bdc98Chandler Carruth// initializer should always be zero to ensure its value can never appear to be
2253930f6d0870b65553f663a2094ca39c3f4bdc98Chandler Carruth// non-zero, even during dynamic initialization.
2353930f6d0870b65553f663a2094ca39c3f4bdc98Chandler Carruthsize_t llvm::hashing::detail::fixed_seed_override = 0;
2453930f6d0870b65553f663a2094ca39c3f4bdc98Chandler Carruth
2553930f6d0870b65553f663a2094ca39c3f4bdc98Chandler Carruth// Implement the function for forced setting of the fixed seed.
2653930f6d0870b65553f663a2094ca39c3f4bdc98Chandler Carruth// FIXME: Use atomic operations here so that there is no data race.
2753930f6d0870b65553f663a2094ca39c3f4bdc98Chandler Carruthvoid llvm::set_fixed_execution_hash_seed(size_t fixed_value) {
2853930f6d0870b65553f663a2094ca39c3f4bdc98Chandler Carruth  hashing::detail::fixed_seed_override = fixed_value;
2953930f6d0870b65553f663a2094ca39c3f4bdc98Chandler Carruth}
30