[llvm] [LTO] Introduce a helper lambda in gatherImportedSummariesForModule (NFC) (PR #106251)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 27 11:25:31 PDT 2024


================
@@ -1293,7 +1293,8 @@ using GVSummaryMapTy = DenseMap<GlobalValue::GUID, GlobalValueSummary *>;
 
 /// Map of a module name to the GUIDs and summaries we will import from that
 /// module.
-using ModuleToSummariesForIndexTy = std::map<std::string, GVSummaryMapTy>;
+using ModuleToSummariesForIndexTy =
+    std::map<std::string, GVSummaryMapTy, std::less<>>;
----------------
kazutakahirata wrote:

Yes.  The default comparison class for `std::map<Key>` is `std::less<Key>`, which provides:

```
  bool operator()(const Key &L, const Key &R) const;
```

Notice that `L` and `R` are of the same type, namely `const Key &`.

In contrast, `std::less<>` provides:

```
  template <typename T1, typename T2>
  bool operator()(const T1 &L, const T2 &R) const;
```

Here, `L` and `R` can be of two different types, which is exactly what we need to compare `std::string` and `StringRef`.

https://github.com/llvm/llvm-project/pull/106251


More information about the llvm-commits mailing list