[llvm] 4e30cf7 - [LTO] Introduce getSourceModules (NFC) (#105955)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 26 11:02:09 PDT 2024
Author: Kazu Hirata
Date: 2024-08-26T11:02:05-07:00
New Revision: 4e30cf7b2a94b502abb10c400255547e50f79648
URL: https://github.com/llvm/llvm-project/commit/4e30cf7b2a94b502abb10c400255547e50f79648
DIFF: https://github.com/llvm/llvm-project/commit/4e30cf7b2a94b502abb10c400255547e50f79648.diff
LOG: [LTO] Introduce getSourceModules (NFC) (#105955)
This patch introduces getSourceModules to compute the list of source
modules in the ascending alphabetical order. The new function is
intended to hide implementation details of ImportMapTy while
simplifying FunctionImporter::importFunctions a little bit.
Added:
Modified:
llvm/include/llvm/Transforms/IPO/FunctionImport.h
llvm/lib/Transforms/IPO/FunctionImport.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Transforms/IPO/FunctionImport.h b/llvm/include/llvm/Transforms/IPO/FunctionImport.h
index 93d831c26938bb..b5b969220df85b 100644
--- a/llvm/include/llvm/Transforms/IPO/FunctionImport.h
+++ b/llvm/include/llvm/Transforms/IPO/FunctionImport.h
@@ -139,6 +139,10 @@ class FunctionImporter {
maybeAddDeclaration(FromModule, GUID);
}
+ // Return the list of source modules sorted in the ascending alphabetical
+ // order.
+ SmallVector<StringRef, 0> getSourceModules() const;
+
const ImportMapTyImpl &getImportMap() const { return ImportMap; }
private:
diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp
index 74a71cbf101b5d..dd01d143b066b9 100644
--- a/llvm/lib/Transforms/IPO/FunctionImport.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp
@@ -352,6 +352,13 @@ void FunctionImporter::ImportMapTy::maybeAddDeclaration(
ImportMap[FromModule].try_emplace(GUID, GlobalValueSummary::Declaration);
}
+SmallVector<StringRef, 0>
+FunctionImporter::ImportMapTy::getSourceModules() const {
+ SmallVector<StringRef, 0> Modules(make_first_range(ImportMap));
+ llvm::sort(Modules);
+ return Modules;
+}
+
/// Import globals referenced by a function or other globals that are being
/// imported, if importing such global is possible.
class GlobalsImporter final {
@@ -1770,11 +1777,6 @@ Expected<bool> FunctionImporter::importFunctions(
unsigned ImportedCount = 0, ImportedGVCount = 0;
IRMover Mover(DestModule);
- // Do the actual import of functions now, one Module at a time
- std::set<StringRef> ModuleNameOrderedList;
- for (const auto &FunctionsToImportPerModule : ImportList.getImportMap()) {
- ModuleNameOrderedList.insert(FunctionsToImportPerModule.first);
- }
auto getImportType = [&](const FunctionsToImportTy &GUIDToImportType,
GlobalValue::GUID GUID)
@@ -1785,7 +1787,8 @@ Expected<bool> FunctionImporter::importFunctions(
return Iter->second;
};
- for (const auto &Name : ModuleNameOrderedList) {
+ // Do the actual import of functions now, one Module at a time
+ for (const auto &Name : ImportList.getSourceModules()) {
// Get the module for the import
const auto &FunctionsToImportPerModule =
ImportList.getImportMap().find(Name);
More information about the llvm-commits
mailing list