@@ -74,6 +74,12 @@ class IndexNode {
7474};
7575} // namespace internal
7676
77+ // Setting initial capacity to 1 because all contexts must have at least 1
78+ // counter, and then, because all contexts belonging to a function have the same
79+ // size, there'll be at most one other heap allocation.
80+ using CtxProfFlatProfile =
81+ std::map<GlobalValue::GUID, SmallVector<uint64_t , 1 >>;
82+
7783// / A node (context) in the loaded contextual profile, suitable for mutation
7884// / during IPO passes. We generally expect a fraction of counters and
7985// / callsites to be populated. We continue to model counters as vectors, but
@@ -93,11 +99,16 @@ class PGOCtxProfContext final : public internal::IndexNode {
9399 GlobalValue::GUID GUID = 0 ;
94100 SmallVector<uint64_t , 16 > Counters;
95101 const std::optional<uint64_t > RootEntryCount;
102+ std::optional<CtxProfFlatProfile> Unhandled{};
96103 CallsiteMapTy Callsites;
97104
98- PGOCtxProfContext (GlobalValue::GUID G, SmallVectorImpl<uint64_t > &&Counters,
99- std::optional<uint64_t > RootEntryCount = std::nullopt )
100- : GUID(G), Counters(std::move(Counters)), RootEntryCount(RootEntryCount) {
105+ PGOCtxProfContext (
106+ GlobalValue::GUID G, SmallVectorImpl<uint64_t > &&Counters,
107+ std::optional<uint64_t > RootEntryCount = std::nullopt ,
108+ std::optional<CtxProfFlatProfile> &&Unhandled = std::nullopt )
109+ : GUID(G), Counters(std::move(Counters)), RootEntryCount(RootEntryCount),
110+ Unhandled (std::move(Unhandled)) {
111+ assert (RootEntryCount.has_value () == Unhandled.has_value ());
101112 }
102113
103114 Expected<PGOCtxProfContext &>
@@ -121,6 +132,8 @@ class PGOCtxProfContext final : public internal::IndexNode {
121132 bool isRoot () const { return RootEntryCount.has_value (); }
122133 uint64_t getTotalRootEntryCount () const { return RootEntryCount.value (); }
123134
135+ const CtxProfFlatProfile &getUnhandled () const { return Unhandled.value (); }
136+
124137 uint64_t getEntrycount () const {
125138 assert (!Counters.empty () &&
126139 " Functions are expected to have at their entry BB instrumented, so "
@@ -170,12 +183,6 @@ class PGOCtxProfContext final : public internal::IndexNode {
170183 }
171184};
172185
173- // Setting initial capacity to 1 because all contexts must have at least 1
174- // counter, and then, because all contexts belonging to a function have the same
175- // size, there'll be at most one other heap allocation.
176- using CtxProfFlatProfile =
177- std::map<GlobalValue::GUID, SmallVector<uint64_t , 1 >>;
178-
179186using CtxProfContextualProfiles =
180187 std::map<GlobalValue::GUID, PGOCtxProfContext>;
181188struct PGOCtxProfile {
@@ -205,6 +212,7 @@ class PGOCtxProfileReader final {
205212
206213 Error loadContexts (CtxProfContextualProfiles &P);
207214 Error loadFlatProfiles (CtxProfFlatProfile &P);
215+ Error loadFlatProfileList (CtxProfFlatProfile &P);
208216
209217public:
210218 PGOCtxProfileReader (StringRef Buffer)
0 commit comments