@@ -422,7 +422,8 @@ bool YAMLProfileReader::profileMatches(
422422}
423423
424424bool YAMLProfileReader::mayHaveProfileData (const BinaryFunction &BF) {
425- if (opts::MatchProfileWithFunctionHash || opts::MatchWithCallGraph)
425+ if (opts::MatchProfileWithFunctionHash || opts::MatchWithCallGraph ||
426+ opts::ProfileUsePseudoProbes)
426427 return true ;
427428 for (StringRef Name : BF.getNames ())
428429 if (ProfileFunctionNames.contains (Name))
@@ -591,6 +592,41 @@ size_t YAMLProfileReader::matchWithCallGraph(BinaryContext &BC) {
591592 return MatchedWithCallGraph;
592593}
593594
595+ size_t YAMLProfileReader::matchWithPseudoProbes (BinaryContext &BC) {
596+ if (!opts::ProfileUsePseudoProbes)
597+ return 0 ;
598+
599+ const MCPseudoProbeDecoder *PseudoProbeDecoder = BC.getPseudoProbeDecoder ();
600+ assert (PseudoProbeDecoder &&
601+ " If pseudo probes are in use, pseudo probe decoder should exist" );
602+ const auto &GUID2FuncDescMap = PseudoProbeDecoder->getGUID2FuncDescMap ();
603+ DenseMap<uint64_t , BinaryFunction *> PseudoProbeDescHashToBF;
604+ DenseMap<uint64_t , BinaryFunction *> GUIDToBF;
605+
606+ for (BinaryFunction *BF : BC.getAllBinaryFunctions ()) {
607+ if (ProfiledFunctions.count (BF))
608+ continue ;
609+ auto It = GUID2FuncDescMap.find (BF->getGUID ());
610+ if (It == GUID2FuncDescMap.end ())
611+ continue ;
612+ PseudoProbeDescHashToBF[It->second .FuncHash ] = BF;
613+ }
614+
615+ uint64_t MatchedWithPseudoProbes = 0 ;
616+ for (yaml::bolt::BinaryFunctionProfile &YamlBF : YamlBP.Functions ) {
617+ auto It = PseudoProbeDescHashToBF.find (YamlBF.Hash );
618+ if (It == PseudoProbeDescHashToBF.end ())
619+ continue ;
620+ BinaryFunction *BF = It->second ;
621+ if (ProfiledFunctions.count (BF))
622+ continue ;
623+ matchProfileToFunction (YamlBF, *BF);
624+ ++MatchedWithPseudoProbes;
625+ }
626+
627+ return MatchedWithPseudoProbes;
628+ }
629+
594630size_t YAMLProfileReader::matchWithNameSimilarity (BinaryContext &BC) {
595631 if (opts::NameSimilarityFunctionMatchingThreshold == 0 )
596632 return 0 ;
@@ -735,6 +771,7 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) {
735771 const size_t MatchedWithLTOCommonName = matchWithLTOCommonName ();
736772 const size_t MatchedWithCallGraph = matchWithCallGraph (BC);
737773 const size_t MatchedWithNameSimilarity = matchWithNameSimilarity (BC);
774+ const size_t MatchedWithPseudoProbes = matchWithPseudoProbes (BC);
738775
739776 for (auto [YamlBF, BF] : llvm::zip_equal (YamlBP.Functions , ProfileBFs))
740777 if (!YamlBF.Used && BF && !ProfiledFunctions.count (BF))
@@ -757,6 +794,8 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) {
757794 << " functions with call graph\n " ;
758795 outs () << " BOLT-INFO: matched " << MatchedWithNameSimilarity
759796 << " functions with similar names\n " ;
797+ outs () << " BOLT-INFO: matched " << MatchedWithPseudoProbes
798+ << " functions with pseudo probes\n " ;
760799 }
761800
762801 // Set for parseFunctionProfile().
0 commit comments