[llvm] [NFCI][WPD]Use unique string saver to store type id (PR #106932)
Mingming Liu via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 20 12:28:11 PST 2024
================
@@ -327,7 +327,20 @@ template <> struct MappingTraits<ModuleSummaryIndex> {
if (!io.outputting())
CustomMappingTraits<GlobalValueSummaryMapTy>::fixAliaseeLinks(
index.GlobalValueMap);
- io.mapOptional("TypeIdMap", index.TypeIdMap);
+
+ if (io.outputting()) {
+ io.mapOptional("TypeIdMap", index.TypeIdMap);
+ } else {
+ TypeIdSummaryMapTy TypeIdMap;
+ io.mapOptional("TypeIdMap", TypeIdMap);
+ for (auto &[TypeGUID, TypeIdSummaryMap] : TypeIdMap) {
+ // Save type id references in index and point TypeIdMap to use the
+ // references owned by index.
+ StringRef KeyRef = index.TypeIdSaver.save(TypeIdSummaryMap.first);
+ index.TypeIdMap.insert({TypeGUID, {KeyRef, TypeIdSummaryMap.second}});
----------------
minglotus-6 wrote:
Before I figured out this way, I tried to change `CustomMappingTraits`. If I read correctly, the input/output methods don't take 'index' as a parameter, and 'TypeIdMap' doesn't have a pointer to 'index' either.
I updated the PR to 'move' `TypeIdSummaryMap.second` in the latest reply. yaml IO is likely not on the critical path, but std::move should be safe to invoke here.
https://github.com/llvm/llvm-project/pull/106932
More information about the llvm-commits
mailing list