[PATCH] D159014: [llvm-profdata] Use std::unordered_map in SampleProfileMap

William Junda Huang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 28 14:10:51 PDT 2023


huangjd added inline comments.


================
Comment at: llvm/include/llvm/ADT/Hashing.h:687-688
+/// Implement std::hash so that hash_code can be used in STL containers.
+template<>
+struct std::hash<llvm::hash_code> {
+  size_t operator()(llvm::hash_code const& Obj) const {
----------------
wenlei wrote:
> Given this is only used by `HashKeyMap` and not really meant to enable general conversion from llvm hash to std hash, consider move it to SampleProf.h right above `SampleProfileMap`. 
> 
> 
This can be problematic, if `llvm::hash_code` is being used in `std::unordered_map` somewhere else and the user defines std::hash<llvm::hash_code> locally, it will cause multiple definition of a class if the header somehow get included. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D159014/new/

https://reviews.llvm.org/D159014



More information about the llvm-commits mailing list