//===--- FunctionId.h - Sample profile function object ----------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// /// /// \file /// /// Defines FunctionId class. /// //===----------------------------------------------------------------------===// #ifndef LLVM_PROFILEDATA_FUNCTIONID_H #define LLVM_PROFILEDATA_FUNCTIONID_H #include "llvm/ADT/DenseMapInfo.h" #include "llvm/ADT/Hashing.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/MD5.h" #include "llvm/Support/raw_ostream.h" #include <cstdint> namespace llvm { namespace sampleprof { /// This class represents a function that is read from a sample profile. It /// comes with two forms: a string or a hash code. The latter form is the 64-bit /// MD5 of the function name for efficient storage supported by ExtBinary /// profile format, and when reading the profile, this class can represent it /// without converting it to a string first. /// When representing a hash code, we utilize the LengthOrHashCode field to /// store it, and Name is set to null. When representing a string, it is same as /// StringRef. class FunctionId { … }; inline bool operator==(const FunctionId &LHS, const FunctionId &RHS) { … } inline bool operator!=(const FunctionId &LHS, const FunctionId &RHS) { … } inline bool operator<(const FunctionId &LHS, const FunctionId &RHS) { … } inline bool operator<=(const FunctionId &LHS, const FunctionId &RHS) { … } inline bool operator>(const FunctionId &LHS, const FunctionId &RHS) { … } inline bool operator>=(const FunctionId &LHS, const FunctionId &RHS) { … } inline raw_ostream &operator<<(raw_ostream &OS, const FunctionId &Obj) { … } inline uint64_t MD5Hash(const FunctionId &Obj) { … } inline uint64_t hash_value(const FunctionId &Obj) { … } } // end namespace sampleprof /// Template specialization for FunctionId so that it can be used in LLVM map /// containers. template <> struct DenseMapInfo<sampleprof::FunctionId, void> { … }; } // end namespace llvm namespace std { /// Template specialization for FunctionId so that it can be used in STL /// containers. template <> struct hash<llvm::sampleprof::FunctionId> { … }; } // end namespace std #endif // LLVM_PROFILEDATA_FUNCTIONID_H