@@ -164,9 +164,24 @@ struct alignas(8) GlobalValueSummaryInfo {
164164
165165 inline GlobalValueSummaryInfo (bool HaveGVs);
166166
167+ // / Access a read-only list of global value summary structures for a
168+ // / particular value held in the GlobalValueMap.
169+ ArrayRef<std::unique_ptr<GlobalValueSummary>> getSummaryList () const {
170+ return SummaryList;
171+ }
172+
173+ // / Add a summary corresponding to a global value definition in a module with
174+ // / the corresponding GUID.
175+ void addSummary (std::unique_ptr<GlobalValueSummary> Summary) {
176+ return SummaryList.push_back (std::move (Summary));
177+ }
178+
179+ private:
167180 // / List of global value summary structures for a particular value held
168181 // / in the GlobalValueMap. Requires a vector in the case of multiple
169- // / COMDAT values of the same name.
182+ // / COMDAT values of the same name, weak symbols, locals of the same name when
183+ // / compiling without sufficient distinguishing path, or (theoretically) hash
184+ // / collisions. Each summary is from a different module.
170185 GlobalValueSummaryList SummaryList;
171186};
172187
@@ -201,7 +216,7 @@ struct ValueInfo {
201216 }
202217
203218 ArrayRef<std::unique_ptr<GlobalValueSummary>> getSummaryList () const {
204- return getRef ()->second .SummaryList ;
219+ return getRef ()->second .getSummaryList () ;
205220 }
206221
207222 // Even if the index is built with GVs available, we may not have one for
@@ -1607,8 +1622,8 @@ class ModuleSummaryIndex {
16071622
16081623 for (auto &S : *this ) {
16091624 // Skip external functions
1610- if (!S.second .SummaryList .size () ||
1611- !isa<FunctionSummary>(S.second .SummaryList .front ().get ()))
1625+ if (!S.second .getSummaryList () .size () ||
1626+ !isa<FunctionSummary>(S.second .getSummaryList () .front ().get ()))
16121627 continue ;
16131628 discoverNodes (ValueInfo (HaveGVs, &S), FunctionHasParent);
16141629 }
@@ -1748,7 +1763,7 @@ class ModuleSummaryIndex {
17481763 // Here we have a notionally const VI, but the value it points to is owned
17491764 // by the non-const *this.
17501765 const_cast <GlobalValueSummaryMapTy::value_type *>(VI.getRef ())
1751- ->second .SummaryList . push_back (std::move (Summary));
1766+ ->second .addSummary (std::move (Summary));
17521767 }
17531768
17541769 // / Add an original name for the value of the given GUID.
@@ -1937,7 +1952,7 @@ class ModuleSummaryIndex {
19371952 collectDefinedGVSummariesPerModule (Map &ModuleToDefinedGVSummaries) const {
19381953 for (const auto &GlobalList : *this ) {
19391954 auto GUID = GlobalList.first ;
1940- for (const auto &Summary : GlobalList.second .SummaryList ) {
1955+ for (const auto &Summary : GlobalList.second .getSummaryList () ) {
19411956 ModuleToDefinedGVSummaries[Summary->modulePath ()][GUID] = Summary.get ();
19421957 }
19431958 }
@@ -2035,7 +2050,7 @@ struct GraphTraits<ModuleSummaryIndex *> : public GraphTraits<ValueInfo> {
20352050 std::unique_ptr<GlobalValueSummary> Root =
20362051 std::make_unique<FunctionSummary>(I->calculateCallGraphRoot ());
20372052 GlobalValueSummaryInfo G (I->haveGVs ());
2038- G.SummaryList . push_back (std::move (Root));
2053+ G.addSummary (std::move (Root));
20392054 static auto P =
20402055 GlobalValueSummaryMapTy::value_type (GlobalValue::GUID (0 ), std::move (G));
20412056 return ValueInfo (I->haveGVs (), &P);
0 commit comments