[llvm] [LTO] Introduce a helper function summarizeImports (NFC) (PR #106179)
Jan Voung via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 27 06:53:41 PDT 2024
================
@@ -1082,21 +1082,29 @@ numGlobalVarSummaries(const ModuleSummaryIndex &Index,
return NumGVS;
}
-// Given ImportMap, return the number of global variable summaries and record
-// the number of defined function summaries as output parameter.
-static unsigned
-numGlobalVarSummaries(const ModuleSummaryIndex &Index,
- const FunctionImporter::FunctionsToImportTy &ImportMap,
- unsigned &DefinedFS) {
+struct ImportSummary {
unsigned NumGVS = 0;
- DefinedFS = 0;
- for (auto &[GUID, Type] : ImportMap) {
- if (isGlobalVarSummary(Index, GUID))
- ++NumGVS;
- else if (Type == GlobalValueSummary::Definition)
- ++DefinedFS;
+ unsigned DefinedFS = 0;
+ unsigned Count = 0;
+};
+
+// Compute import summary for each source module in ImportList.
+static DenseMap<StringRef, ImportSummary>
+summarizeImports(const ModuleSummaryIndex &Index,
+ const FunctionImporter::ImportMapTy &ImportList) {
+ DenseMap<StringRef, ImportSummary> Histogram;
+
+ for (const auto &[FromModule, GUIDs] : ImportList.getImportMap()) {
+ for (const auto &[GUID, Type] : GUIDs) {
+ ImportSummary &Entry = Histogram[FromModule];
----------------
jvoung wrote:
Can the Entry lookup be lifted to the outer loop (only depending on FromModule)?
https://github.com/llvm/llvm-project/pull/106179
More information about the llvm-commits
mailing list