@@ -91,6 +91,15 @@ uint64_t BasicBlockSectionsProfileReader::getEdgeCount(
9191 return EdgeIt->second ;
9292}
9393
94+ std::pair<bool , FunctionPathAndClusterInfo>
95+ BasicBlockSectionsProfileReader::getFunctionPathAndClusterInfo (
96+ StringRef FuncName) const {
97+ auto R = ProgramPathAndClusterInfo.find (getAliasName (FuncName));
98+ return R != ProgramPathAndClusterInfo.end ()
99+ ? std::pair (true , R->second )
100+ : std::pair (false , FunctionPathAndClusterInfo ());
101+ }
102+
94103// Reads the version 1 basic block sections profile. Profile for each function
95104// is encoded as follows:
96105// m <module_name>
@@ -287,6 +296,25 @@ Error BasicBlockSectionsProfileReader::ReadV1Profile() {
287296 }
288297 continue ;
289298 }
299+ case ' h' : { // Basic block hash secifier.
300+ // Skip the profile when we the profile iterator (FI) refers to the
301+ // past-the-end element.
302+ if (FI == ProgramPathAndClusterInfo.end ())
303+ continue ;
304+ for (auto BBIDHashStr : Values) {
305+ auto [BBIDStr, HashStr] = BBIDHashStr.split (' :' );
306+ unsigned long long BBID = 0 , Hash = 0 ;
307+ if (getAsUnsignedInteger (BBIDStr, 10 , BBID))
308+ return createProfileParseError (Twine (" unsigned integer expected: '" ) +
309+ BBIDStr + " '" );
310+ HashStr.consume_front (" 0x" );
311+ if (getAsUnsignedInteger (HashStr, 16 , Hash))
312+ return createProfileParseError (Twine (" unsigned integer expected: '" ) +
313+ HashStr + " '" );
314+ FI->second .BBHashes [BBID] = Hash;
315+ }
316+ continue ;
317+ }
290318 default :
291319 return createProfileParseError (Twine (" invalid specifier: '" ) +
292320 Twine (Specifier) + " '" );
@@ -493,6 +521,12 @@ uint64_t BasicBlockSectionsProfileReaderWrapperPass::getEdgeCount(
493521 return BBSPR.getEdgeCount (FuncName, SrcBBID, SinkBBID);
494522}
495523
524+ std::pair<bool , FunctionPathAndClusterInfo>
525+ BasicBlockSectionsProfileReaderWrapperPass::getFunctionPathAndClusterInfo (
526+ StringRef FuncName) const {
527+ return BBSPR.getFunctionPathAndClusterInfo (FuncName);
528+ }
529+
496530BasicBlockSectionsProfileReader &
497531BasicBlockSectionsProfileReaderWrapperPass::getBBSPR () {
498532 return BBSPR;
0 commit comments