================ @@ -215,13 +215,49 @@ class FunctionImporter { SmallVector<StringRef, 0> getSourceModules() const; std::optional<GlobalValueSummary::ImportKind> - getImportType(const FunctionsToImportTy &GUIDToImportType, - GlobalValue::GUID GUID) const; + getImportType(StringRef FromModule, GlobalValue::GUID GUID) const; + + // Iterate over the import list. The caller gets tuples of FromModule, + // GUID, and ImportKind instead of import IDs. + auto begin() const { return map_iterator(Imports.begin(), IDs); } + auto end() const { return map_iterator(Imports.end(), IDs); } + + friend class SortedImportList; + + private: + ImportIDTable &IDs; + DenseSet<ImportIDTable::ImportIDTy> Imports; + }; + + // A read-only copy of ImportMapTy with its contents sorted according to the + // given comparison function. + class SortedImportList { + public: + SortedImportList(const ImportMapTy &ImportMap, + llvm::function_ref< + bool(const std::pair<StringRef, GlobalValue::GUID> &, + const std::pair<StringRef, GlobalValue::GUID> &)> + Comp) + : IDs(ImportMap.IDs), Imports(iterator_range(ImportMap.Imports)) { + llvm::sort(Imports, [&](ImportIDTable::ImportIDTy L, ---------------- kazutakahirata wrote:
May I ask why? `llvm::stable_sort` implies that the original order matters in some way, but the original order here is the iteration order of `DenseSet`. There is nothing worth preserving there. https://github.com/llvm/llvm-project/pull/106772 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits