[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 15:30:35 PDT 2023
huangjd updated this revision to Diff 554076.
huangjd added a comment.
Coding style update
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D159014/new/
https://reviews.llvm.org/D159014
Files:
llvm/include/llvm/ADT/Hashing.h
llvm/include/llvm/ProfileData/SampleProf.h
Index: llvm/include/llvm/ProfileData/SampleProf.h
===================================================================
--- llvm/include/llvm/ProfileData/SampleProf.h
+++ llvm/include/llvm/ProfileData/SampleProf.h
@@ -1412,7 +1412,7 @@
/// Note: when populating container, make sure to assign the SampleContext to
/// the mapped value immediately because the key no longer holds it.
class SampleProfileMap
- : public HashKeyMap<DenseMap, SampleContext, FunctionSamples> {
+ : public HashKeyMap<std::unordered_map, SampleContext, FunctionSamples> {
public:
// Convenience method because this is being used in many places. Set the
// FunctionSamples' context if its newly inserted.
@@ -1424,12 +1424,12 @@
}
iterator find(const SampleContext &Ctx) {
- return HashKeyMap<llvm::DenseMap, SampleContext, FunctionSamples>::find(
+ return HashKeyMap<std::unordered_map, SampleContext, FunctionSamples>::find(
Ctx);
}
const_iterator find(const SampleContext &Ctx) const {
- return HashKeyMap<llvm::DenseMap, SampleContext, FunctionSamples>::find(
+ return HashKeyMap<std::unordered_map, SampleContext, FunctionSamples>::find(
Ctx);
}
@@ -1449,8 +1449,8 @@
}
size_t erase(const SampleContext &Ctx) {
- return HashKeyMap<llvm::DenseMap, SampleContext, FunctionSamples>::erase(
- Ctx);
+ return HashKeyMap<std::unordered_map, SampleContext, FunctionSamples>::
+ erase(Ctx);
}
size_t erase(const key_type &Key) { return base_type::erase(Key); }
Index: llvm/include/llvm/ADT/Hashing.h
===================================================================
--- llvm/include/llvm/ADT/Hashing.h
+++ llvm/include/llvm/ADT/Hashing.h
@@ -683,4 +683,16 @@
} // namespace llvm
+/// Implement std::hash so that hash_code can be used in STL containers.
+namespace std {
+
+template<>
+struct hash<llvm::hash_code> {
+ size_t operator()(llvm::hash_code const& Val) const {
+ return Val;
+ }
+};
+
+} // namespace std;
+
#endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D159014.554076.patch
Type: text/x-patch
Size: 2012 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230828/018fe61c/attachment.bin>
More information about the llvm-commits
mailing list