1 //=-- InstrProfIndexed.h - Indexed profiling format support -------*- C++ -*-=//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Shared header for the instrumented profile data reader and writer.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_PROFILEDATA_INSTRPROFINDEXED_H
15 #define LLVM_LIB_PROFILEDATA_INSTRPROFINDEXED_H
17 #include "llvm/Support/Endian.h"
18 #include "llvm/Support/ErrorHandling.h"
19 #include "llvm/Support/MD5.h"
23 namespace IndexedInstrProf {
24 enum class HashT : uint32_t {
30 static inline uint64_t MD5Hash(StringRef Str) {
33 llvm::MD5::MD5Result Result;
35 // Return the least significant 8 bytes. Our MD5 implementation returns the
36 // result in little endian, so we may need to swap bytes.
37 using namespace llvm::support;
38 return endian::read<uint64_t, little, unaligned>(Result);
41 static inline uint64_t ComputeHash(HashT Type, StringRef K) {
44 return IndexedInstrProf::MD5Hash(K);
46 llvm_unreachable("Unhandled hash type");
49 const uint64_t Magic = 0x8169666f72706cff; // "\xfflprofi\x81"
50 const uint64_t Version = 2;
51 const HashT HashType = HashT::MD5;
54 } // end namespace llvm