Skip to content

[LTO] Teach computeLTOCacheKey to return std::string (NFC) #105331

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions llvm/include/llvm/LTO/LTO.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,9 @@ void thinLTOInternalizeAndPromoteInIndex(

/// Computes a unique hash for the Module considering the current list of
/// export/import and other global analysis results.
/// The hash is produced in \p Key.
void computeLTOCacheKey(
SmallString<40> &Key, const lto::Config &Conf,
const ModuleSummaryIndex &Index, StringRef ModuleID,
const FunctionImporter::ImportMapTy &ImportList,
std::string computeLTOCacheKey(
const lto::Config &Conf, const ModuleSummaryIndex &Index,
StringRef ModuleID, const FunctionImporter::ImportMapTy &ImportList,
const FunctionImporter::ExportSetTy &ExportList,
const std::map<GlobalValue::GUID, GlobalValue::LinkageTypes> &ResolvedODR,
const GVSummaryMapTy &DefinedGlobals,
Expand Down
17 changes: 8 additions & 9 deletions llvm/lib/LTO/LTO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ extern cl::opt<bool> EnableMemProfContextDisambiguation;

// Computes a unique hash for the Module considering the current list of
// export/import and other global analysis results.
// The hash is produced in \p Key.
void llvm::computeLTOCacheKey(
SmallString<40> &Key, const Config &Conf, const ModuleSummaryIndex &Index,
StringRef ModuleID, const FunctionImporter::ImportMapTy &ImportList,
// Returns the hash in its hexadecimal representation.
std::string llvm::computeLTOCacheKey(
const Config &Conf, const ModuleSummaryIndex &Index, StringRef ModuleID,
const FunctionImporter::ImportMapTy &ImportList,
const FunctionImporter::ExportSetTy &ExportList,
const std::map<GlobalValue::GUID, GlobalValue::LinkageTypes> &ResolvedODR,
const GVSummaryMapTy &DefinedGlobals,
Expand Down Expand Up @@ -355,7 +355,7 @@ void llvm::computeLTOCacheKey(
}
}

Key = toHex(Hasher.result());
return toHex(Hasher.result());
}

static void thinLTOResolvePrevailingGUID(
Expand Down Expand Up @@ -1488,11 +1488,10 @@ class InProcessThinBackend : public ThinBackendProc {
// no module hash.
return RunThinBackend(AddStream);

SmallString<40> Key;
// The module may be cached, this helps handling it.
computeLTOCacheKey(Key, Conf, CombinedIndex, ModuleID, ImportList,
ExportList, ResolvedODR, DefinedGlobals, CfiFunctionDefs,
CfiFunctionDecls);
std::string Key = computeLTOCacheKey(
Conf, CombinedIndex, ModuleID, ImportList, ExportList, ResolvedODR,
DefinedGlobals, CfiFunctionDefs, CfiFunctionDecls);
Expected<AddStreamFn> CacheAddStreamOrErr = Cache(Task, Key, ModuleID);
if (Error Err = CacheAddStreamOrErr.takeError())
return Err;
Expand Down
8 changes: 4 additions & 4 deletions llvm/lib/LTO/ThinLTOCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,13 +382,13 @@ class ModuleCacheEntry {
Conf.RelocModel = TMBuilder.RelocModel;
Conf.CGOptLevel = TMBuilder.CGOptLevel;
Conf.Freestanding = Freestanding;
SmallString<40> Key;
computeLTOCacheKey(Key, Conf, Index, ModuleID, ImportList, ExportList,
ResolvedODR, DefinedGVSummaries);
std::string Key =
computeLTOCacheKey(Conf, Index, ModuleID, ImportList, ExportList,
ResolvedODR, DefinedGVSummaries);

// This choice of file name allows the cache to be pruned (see pruneCache()
// in include/llvm/Support/CachePruning.h).
sys::path::append(EntryPath, CachePath, "llvmcache-" + Key);
sys::path::append(EntryPath, CachePath, Twine("llvmcache-", Key));
}

// Access the path to this entry in the cache.
Expand Down
Loading