[llvm-branch-commits] [llvm] [BOLT][NFC] Refactor function matching (PR #97502)
@@ -456,6 +435,39 @@ Error YAMLProfileReader::readProfile(BinaryContext ) { ++MatchedWithLTOCommonName; } } + return MatchedWithLTOCommonName; +} + +Error YAMLProfileReader::readProfile(BinaryContext ) { + if (opts::Verbosity >= 1) { +outs() << "BOLT-INFO: YAML profile with hash: "; +switch (YamlBP.Header.HashFunction) { +case HashFunction::StdHash: + outs() << "std::hash\n"; ayermolo wrote: BC.outs() https://github.com/llvm/llvm-project/pull/97502 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT][NFC] Refactor function matching (PR #97502)
@@ -456,6 +435,39 @@ Error YAMLProfileReader::readProfile(BinaryContext ) { ++MatchedWithLTOCommonName; } } + return MatchedWithLTOCommonName; +} + +Error YAMLProfileReader::readProfile(BinaryContext ) { + if (opts::Verbosity >= 1) { +outs() << "BOLT-INFO: YAML profile with hash: "; +switch (YamlBP.Header.HashFunction) { +case HashFunction::StdHash: + outs() << "std::hash\n"; + break; +case HashFunction::XXH3: + outs() << "xxh3\n"; + break; +} + } + YamlProfileToFunction.resize(YamlBP.Functions.size() + 1); + + // Computes hash for binary functions. + if (opts::MatchProfileWithFunctionHash) { +for (auto &[_, BF] : BC.getBinaryFunctions()) { + BF.computeHash(YamlBP.Header.IsDFSOrder, YamlBP.Header.HashFunction); +} + } else if (!opts::IgnoreHash) { +for (BinaryFunction *BF : ProfileBFs) { + if (!BF) +continue; + BF->computeHash(YamlBP.Header.IsDFSOrder, YamlBP.Header.HashFunction); +} + } + + size_t MatchedWithExactName = matchWithExactName(); ayermolo wrote: This doesn't look like it's used anywhere? https://github.com/llvm/llvm-project/pull/97502 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
@@ -374,15 +377,33 @@ Error YAMLProfileReader::readProfile(BinaryContext ) { // the profile. Function.setExecutionCount(BinaryFunction::COUNT_NO_PROFILE); -// Recompute hash once per function. -if (!opts::IgnoreHash) - Function.computeHash(YamlBP.Header.IsDFSOrder, - YamlBP.Header.HashFunction); - if (profileMatches(YamlBF, Function)) matchProfileToFunction(YamlBF, Function); } + // Uses the strict hash of profiled and binary functions to match functions + // that are not matched by name or common name. + if (!opts::IgnoreHash) { +std::unordered_map StrictHashToBF; +StrictHashToBF.reserve(BC.getBinaryFunctions().size()); + +for (auto &[_, BF] : BC.getBinaryFunctions()) { + StrictHashToBF[BF.getHash()] = +} + +for (auto YamlBF : YamlBP.Functions) { ayermolo wrote: Specify actual type. This can also hide copy since & is not used. https://github.com/llvm/llvm-project/pull/95821 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
@@ -374,15 +377,33 @@ Error YAMLProfileReader::readProfile(BinaryContext ) { // the profile. Function.setExecutionCount(BinaryFunction::COUNT_NO_PROFILE); -// Recompute hash once per function. -if (!opts::IgnoreHash) - Function.computeHash(YamlBP.Header.IsDFSOrder, - YamlBP.Header.HashFunction); - if (profileMatches(YamlBF, Function)) matchProfileToFunction(YamlBF, Function); } + // Uses the strict hash of profiled and binary functions to match functions + // that are not matched by name or common name. + if (!opts::IgnoreHash) { +std::unordered_map StrictHashToBF; +StrictHashToBF.reserve(BC.getBinaryFunctions().size()); + +for (auto &[_, BF] : BC.getBinaryFunctions()) { ayermolo wrote: no need for {} since it's one line. https://github.com/llvm/llvm-project/pull/95821 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [bolt] Revise IDE folder structure (PR #89742)
@@ -121,7 +123,7 @@ option(BOLT_BUILD_TOOLS "Build the BOLT tools. If OFF, just generate build targets." ON) add_custom_target(bolt) -set_target_properties(bolt PROPERTIES FOLDER "BOLT") +set_target_properties(bolt PROPERTIES FOLDER "BOLT/Meta") ayermolo wrote: This probably should be something more neutral then a company name. https://github.com/llvm/llvm-project/pull/89742 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [BOLT] Use aggregated FuncBranchData in writeBATYAML (PR #91289)
https://github.com/ayermolo approved this pull request. https://github.com/llvm/llvm-project/pull/91289 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [BOLT] Use aggregated FuncBranchData in writeBATYAML (PR #91289)
@@ -2386,25 +2362,26 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext , return std::pair(BlockIt->first, BlockIt->second.getBBIndex()); }; - for (const auto &[FromOffset, SuccKV] : Branches.IntraIndex) { -const auto &[_, Index] = getBlock(FromOffset); -yaml::bolt::BinaryBasicBlockProfile = YamlBF.Blocks[Index]; -for (const auto &[SuccOffset, SuccDataIdx] : SuccKV) - if (BlockMap.isInputBlock(SuccOffset)) -YamlBB.Successors.emplace_back( -getSuccessorInfo(SuccOffset, SuccDataIdx)); - } - for (const auto &[FromOffset, CallTo] : Branches.InterIndex) { -const auto &[BlockOffset, BlockIndex] = getBlock(FromOffset); -yaml::bolt::BinaryBasicBlockProfile = YamlBF.Blocks[BlockIndex]; -const uint32_t Offset = FromOffset - BlockOffset; -for (const auto &[CallToLoc, CallToIdx] : CallTo) - YamlBB.CallSites.emplace_back( - getCallSiteInfo(CallToLoc, CallToIdx, Offset)); -llvm::sort(YamlBB.CallSites, [](yaml::bolt::CallSiteInfo , -yaml::bolt::CallSiteInfo ) { - return A.Offset < B.Offset; -}); + for (const llvm::bolt::BranchInfo : Branches.Data) { +using namespace yaml::bolt; +const auto &[BlockOffset, BlockIndex] = getBlock(BI.From.Offset); +BinaryBasicBlockProfile = YamlBF.Blocks[BlockIndex]; +if (BI.To.IsSymbol && BI.To.Name == BI.From.Name && BI.To.Offset != 0) { + // Internal branch + const unsigned SuccIndex = getBlock(BI.To.Offset).second; + auto = YamlBB.Successors.emplace_back(SuccessorInfo{SuccIndex}); + SI.Count = BI.Branches; ayermolo wrote: Why can't this be part of constructor? https://github.com/llvm/llvm-project/pull/91289 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [BOLT][BAT] Fix encoded NumBasicBlocks (PR #87830)
https://github.com/ayermolo approved this pull request. https://github.com/llvm/llvm-project/pull/87830 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [BOLT][BAT] Fix encoded NumBasicBlocks (PR #87830)
@@ -426,8 +426,9 @@ void BoltAddressTranslation::dump(raw_ostream ) { for (const auto : Maps) { const uint64_t Address = MapEntry.first; const uint64_t HotAddress = fetchParentAddress(Address); +bool IsHotFunction = HotAddress == 0; ayermolo wrote: const https://github.com/llvm/llvm-project/pull/87830 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [BOLT][BAT] Fix encoded NumBasicBlocks (PR #87830)
@@ -444,6 +444,8 @@ void BoltAddressTranslation::dump(raw_ostream ) { OS << formatv(" hash: {0:x}", BBHashMap.getBBHash(Val)); OS << "\n"; } +if (HotAddress == 0) ayermolo wrote: Can you add a comment on why we output on !HotAddress? https://github.com/llvm/llvm-project/pull/87830 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Use BAT interfaces in YAMLProfileWriter::convert (PR #86219)
ayermolo wrote: I don't think Test plan in summary is necessary. https://github.com/llvm/llvm-project/pull/86219 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [BOLT][NFC] Simplify YAMLProfileWriter::convert (PR #82129)
https://github.com/ayermolo approved this pull request. https://github.com/llvm/llvm-project/pull/82129 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits