-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[LTO] Turn ImportMapTy into a proper class (NFC) #105748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,13 +96,54 @@ class FunctionImporter { | |
std::tuple<unsigned, const GlobalValueSummary *, | ||
std::unique_ptr<ImportFailureInfo>>>; | ||
|
||
/// The map contains an entry for every module to import from, the key being | ||
/// the module identifier to pass to the ModuleLoader. The value is the set of | ||
/// functions to import. The module identifier strings must be owned | ||
/// elsewhere, typically by the in-memory ModuleSummaryIndex the importing | ||
/// decisions are made from (the module path for each summary is owned by the | ||
/// index's module path string table). | ||
using ImportMapTy = DenseMap<StringRef, FunctionsToImportTy>; | ||
/// The map maintains the list of imports. Conceptually, it is a collection | ||
/// of tuples of the form: | ||
/// | ||
/// (The name of the source module, GUID, Definition/Declaration) | ||
/// | ||
/// The name of the source module is the module identifier to pass to the | ||
/// ModuleLoader. The module identifier strings must be owned elsewhere, | ||
/// typically by the in-memory ModuleSummaryIndex the importing decisions are | ||
/// made from (the module path for each summary is owned by the index's module | ||
/// path string table). | ||
class ImportMapTy { | ||
public: | ||
using ImportMapTyImpl = DenseMap<StringRef, FunctionsToImportTy>; | ||
|
||
enum class AddDefinitionStatus { | ||
// No change was made to the list of imports or whether each import should | ||
// be imported as a declaration or definition. | ||
NoChange, | ||
// Successfully added the given GUID to be imported as a definition. There | ||
// was no existing entry with the same GUID as a declaration. | ||
Inserted, | ||
// An existing with the given GUID was changed to a definition. | ||
ChangedToDefinition, | ||
}; | ||
|
||
// Add the given GUID to ImportList as a definition. If the same GUID has | ||
// been added as a declaration previously, that entry is overridden. | ||
AddDefinitionStatus addDefinition(StringRef FromModule, | ||
GlobalValue::GUID GUID); | ||
|
||
// Add the given GUID to ImportList as a declaration. If the same GUID has | ||
// been added as a definition previously, that entry takes precedence, and | ||
// no change is made. | ||
void maybeAddDeclaration(StringRef FromModule, GlobalValue::GUID GUID); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: make these two private methods of class There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd like to keep |
||
|
||
void addGUID(StringRef FromModule, GlobalValue::GUID GUID, | ||
GlobalValueSummary::ImportKind ImportKind) { | ||
if (ImportKind == GlobalValueSummary::Definition) | ||
addDefinition(FromModule, GUID); | ||
else | ||
maybeAddDeclaration(FromModule, GUID); | ||
} | ||
|
||
const ImportMapTyImpl &getImportMap() const { return ImportMap; } | ||
|
||
private: | ||
ImportMapTyImpl ImportMap; | ||
}; | ||
|
||
/// The set contains an entry for every global value that the module exports. | ||
/// Depending on the user context, this container is allowed to contain | ||
|
@@ -122,33 +163,6 @@ class FunctionImporter { | |
/// Import functions in Module \p M based on the supplied import list. | ||
Expected<bool> importFunctions(Module &M, const ImportMapTy &ImportList); | ||
|
||
enum class AddDefinitionStatus { | ||
NoChange, | ||
Inserted, | ||
ChangedToDefinition, | ||
}; | ||
|
||
// Add the given GUID to ImportList as a definition. If the same GUID has | ||
// been added as a declaration previously, that entry is overridden. | ||
static AddDefinitionStatus addDefinition(ImportMapTy &ImportList, | ||
StringRef FromModule, | ||
GlobalValue::GUID GUID); | ||
|
||
// Add the given GUID to ImportList as a declaration. If the same GUID has | ||
// been added as a definition previously, that entry takes precedence, and no | ||
// change is made. | ||
static void maybeAddDeclaration(ImportMapTy &ImportList, StringRef FromModule, | ||
GlobalValue::GUID GUID); | ||
|
||
static void addGUID(ImportMapTy &ImportList, StringRef FromModule, | ||
GlobalValue::GUID GUID, | ||
GlobalValueSummary::ImportKind ImportKind) { | ||
if (ImportKind == GlobalValueSummary::Definition) | ||
addDefinition(ImportList, FromModule, GUID); | ||
else | ||
maybeAddDeclaration(ImportList, FromModule, GUID); | ||
} | ||
|
||
private: | ||
/// The summaries index used to trigger importing. | ||
const ModuleSummaryIndex &Index; | ||
|
Uh oh!
There was an error while loading. Please reload this page.