[llvm-branch-commits] [SHT_LLVM_FUNC_MAP][CodeGen]Introduce function address map section and emit dynamic instruction count(CodeGen part) (PR #124334)

2025-02-14 Thread Lei Wang via llvm-branch-commits
https://github.com/wlei-llvm updated https://github.com/llvm/llvm-project/pull/124334 ___ 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] [SHT_LLVM_FUNC_MAP][CodeGen]Introduce function address map section and emit dynamic instruction count(CodeGen part) (PR #124334)

2025-02-14 Thread Lei Wang via llvm-branch-commits
https://github.com/wlei-llvm updated https://github.com/llvm/llvm-project/pull/124334 ___ 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] [SHT_LLVM_FUNC_MAP][CodeGen]Introduce function address map section and emit dynamic instruction count(CodeGen part) (PR #124334)

2025-02-12 Thread Lei Wang via llvm-branch-commits
https://github.com/wlei-llvm updated https://github.com/llvm/llvm-project/pull/124334 ___ 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] [SHT_LLVM_FUNC_MAP][CodeGen]Introduce function address map section and emit dynamic instruction count(CodeGen part) (PR #124334)

2025-02-12 Thread Lei Wang via llvm-branch-commits
https://github.com/wlei-llvm updated https://github.com/llvm/llvm-project/pull/124334 ___ 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] [SHT_LLVM_FUNC_MAP][llvm-readobj]Introduce function address map section and emit dynamic instruction count(readobj part) (PR #124333)

2025-02-12 Thread Lei Wang via llvm-branch-commits
https://github.com/wlei-llvm updated https://github.com/llvm/llvm-project/pull/124333 >From 0f1f43a5f19d4055c1896a70e050965b4d309790 Mon Sep 17 00:00:00 2001 From: wlei Date: Wed, 12 Feb 2025 22:03:21 -0800 Subject: [PATCH] remove irrelevant code Created using spr 1.3.6-beta.1 --- llvm/tools/

[llvm-branch-commits] [SHT_LLVM_FUNC_MAP][llvm-readobj]Introduce function address map section and emit dynamic instruction count(readobj part) (PR #124333)

2025-02-12 Thread Lei Wang via llvm-branch-commits
https://github.com/wlei-llvm updated https://github.com/llvm/llvm-project/pull/124333 ___ 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] [SHT_LLVM_FUNC_MAP][llvm-readobj]Introduce function address map section and emit dynamic instruction count(readobj part) (PR #124333)

2025-02-12 Thread Lei Wang via llvm-branch-commits
https://github.com/wlei-llvm updated https://github.com/llvm/llvm-project/pull/124333 ___ 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] [Draft] add func map section header (PR #125649)

2025-02-03 Thread Lei Wang via llvm-branch-commits
https://github.com/wlei-llvm edited https://github.com/llvm/llvm-project/pull/125649 ___ 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] [TMP] add func map section header (PR #125649)

2025-02-03 Thread Lei Wang via llvm-branch-commits
https://github.com/wlei-llvm created https://github.com/llvm/llvm-project/pull/125649 Test Plan: llvm/test/CodeGen/X86/function-address-map-function-sections.ll ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.

[llvm-branch-commits] [SHT_LLVM_FUNC_MAP][CodeGen]Introduce function address map section and emit dynamic instruction count(CodeGen part) (PR #124334)

2025-01-27 Thread Lei Wang via llvm-branch-commits
https://github.com/wlei-llvm updated https://github.com/llvm/llvm-project/pull/124334 ___ 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] [SHT_LLVM_FUNC_MAP][CodeGen]Introduce function address map section and emit dynamic instruction count(CodeGen part) (PR #124334)

2025-01-27 Thread Lei Wang via llvm-branch-commits
https://github.com/wlei-llvm updated https://github.com/llvm/llvm-project/pull/124334 ___ 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] [SHT_LLVM_FUNC_MAP][CodeGen]Introduce function address map section and emit dynamic instruction count(CodeGen part) (PR #124334)

2025-01-27 Thread Lei Wang via llvm-branch-commits
https://github.com/wlei-llvm edited https://github.com/llvm/llvm-project/pull/124334 ___ 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] [SHT_LLVM_FUNC_MAP][llvm-readobj]Introduce function address map section and emit dynamic instruction count(readobj part) (PR #124333)

2025-01-27 Thread Lei Wang via llvm-branch-commits
https://github.com/wlei-llvm updated https://github.com/llvm/llvm-project/pull/124333 ___ 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] [SHT_LLVM_FUNC_MAP][llvm-readobj]Introduce function address map section and emit dynamic instruction count(readobj part) (PR #124333)

2025-01-27 Thread Lei Wang via llvm-branch-commits
https://github.com/wlei-llvm updated https://github.com/llvm/llvm-project/pull/124333 ___ 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] [SHT_LLVM_FUNC_MAP][llvm-readobj]Introduce function address map section and emit dynamic instruction count(readobj part) (PR #124333)

2025-01-27 Thread Lei Wang via llvm-branch-commits
https://github.com/wlei-llvm edited https://github.com/llvm/llvm-project/pull/124333 ___ 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] [SHT_LLVM_FUNC_MAP][CodeGen]Introduce function address map section and emit dynamic instruction count(CodeGen part) (PR #124334)

2025-01-24 Thread Lei Wang via llvm-branch-commits
https://github.com/wlei-llvm created https://github.com/llvm/llvm-project/pull/124334 Test Plan: llvm/test/CodeGen/X86/function-address-map-function-sections.ll ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.

[llvm-branch-commits] [SHT_LLVM_FUNC_MAP][llvm-readobj]Introduce function address map section and emit dynamic instruction count(readobj part) (PR #124333)

2025-01-24 Thread Lei Wang via llvm-branch-commits
https://github.com/wlei-llvm created https://github.com/llvm/llvm-project/pull/124333 Test Plan: llvm/test/tools/llvm-readobj/ELF/func-map.test ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/

[llvm-branch-commits] [llvm] [MC] Use StringRefs from pseudo_probe_desc section if it's mapped (PR #112996)

2024-11-08 Thread Lei Wang via llvm-branch-commits
https://github.com/wlei-llvm approved this pull request. Sorry for the delay, LGTM. https://github.com/llvm/llvm-project/pull/112996 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo

[llvm-branch-commits] [llvm] [BOLT] Match blocks with pseudo probes (PR #99891)

2024-11-06 Thread Lei Wang via llvm-branch-commits
@@ -447,12 +561,12 @@ createFlowFunction(const BinaryFunction::BasicBlockOrderType &BlockOrder) { /// of the basic blocks in the binary, the count is "matched" to the block. /// Similarly, if both the source and the target of a count in the profile are /// matched to a jump in

[llvm-branch-commits] [llvm] [BOLT] Match blocks with pseudo probes (PR #99891)

2024-11-06 Thread Lei Wang via llvm-branch-commits
@@ -482,11 +596,68 @@ matchWeightsByHashes(BinaryContext &BC, << Twine::utohexstr(BB->getHash()) << "\n"); } StaleMatcher Matcher; + // Collects function pseudo probes for use in the StaleMatcher. + if (opts::StaleMatchingWithPseudoProbes) { +con

[llvm-branch-commits] [llvm] [BOLT] Match blocks with pseudo probes (PR #99891)

2024-11-06 Thread Lei Wang via llvm-branch-commits
wlei-llvm wrote: > > Ping @wlei-llvm > > Sorry for the delay. The new version addressed my last comment (with just > minor nits). However, I didn't fully follow the new features related to > `ProbeMatchSpecs` stuffs. Could you add more descriptions to the diff > summary? Or if it’s not a lot

[llvm-branch-commits] [llvm] [BOLT] Match blocks with pseudo probes (PR #99891)

2024-10-28 Thread Lei Wang via llvm-branch-commits
@@ -628,9 +618,75 @@ void YAMLProfileReader::InlineTreeNodeMapTy::matchInlineTrees( } } } -if (Cur && Decoder.getFuncDescForGUID(GUID)->FuncHash == Hash) +// Don't match nodes if the profile is stale (mismatching binary FuncHash +// and YAML Hash)

[llvm-branch-commits] [llvm] [BOLT] Match blocks with pseudo probes (PR #99891)

2024-10-28 Thread Lei Wang via llvm-branch-commits
@@ -722,12 +722,28 @@ class BinaryContext { /// Stats for stale profile matching: /// the total number of basic blocks in the profile uint32_t NumStaleBlocks{0}; -/// the number of matched basic blocks -uint32_t NumMatchedBlocks{0}; +/// the number

[llvm-branch-commits] [llvm] [BOLT] Match blocks with pseudo probes (PR #99891)

2024-10-28 Thread Lei Wang via llvm-branch-commits
wlei-llvm wrote: > Ping @wlei-llvm Sorry for the delay. The new version addressed my last comment (with just minor nits). However, I didn't fully follow the new features related to `ProbeMatchSpecs` stuffs. Could you add more descriptions to the diff summary? Or if it’s not a lot of work, cou

[llvm-branch-commits] [llvm] [BOLT] Add profile density computation (PR #101094)

2024-10-24 Thread Lei Wang via llvm-branch-commits
https://github.com/wlei-llvm approved this pull request. LGTM, thanks! https://github.com/llvm/llvm-project/pull/101094 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-

[llvm-branch-commits] [llvm] [BOLT] Match blocks with pseudo probes (PR #99891)

2024-09-18 Thread Lei Wang via llvm-branch-commits
@@ -587,6 +590,51 @@ size_t YAMLProfileReader::matchWithCallGraph(BinaryContext &BC) { return MatchedWithCallGraph; } +void YAMLProfileReader::InlineTreeNodeMapTy::matchInlineTrees( +const MCPseudoProbeDecoder &Decoder, +const yaml::bolt::PseudoProbeDesc &YamlPD, +

[llvm-branch-commits] [llvm] [BOLT] Match blocks with pseudo probes (PR #99891)

2024-09-18 Thread Lei Wang via llvm-branch-commits
@@ -587,6 +590,51 @@ size_t YAMLProfileReader::matchWithCallGraph(BinaryContext &BC) { return MatchedWithCallGraph; } +void YAMLProfileReader::InlineTreeNodeMapTy::matchInlineTrees( +const MCPseudoProbeDecoder &Decoder, +const yaml::bolt::PseudoProbeDesc &YamlPD, +

[llvm-branch-commits] [llvm] [BOLT] Match blocks with pseudo probes (PR #99891)

2024-09-18 Thread Lei Wang via llvm-branch-commits
@@ -96,6 +101,42 @@ class YAMLProfileReader : public ProfileReaderBase { YamlBFAdjacencyMap; }; + // A class for matching inline tree nodes between profile and binary. + class InlineTreeNodeMapTy { +DenseMap Map; + +void mapInlineTreeNode(uint32_t ProfileNo

[llvm-branch-commits] [llvm] [BOLT] Match blocks with pseudo probes (PR #99891)

2024-09-18 Thread Lei Wang via llvm-branch-commits
@@ -587,6 +590,51 @@ size_t YAMLProfileReader::matchWithCallGraph(BinaryContext &BC) { return MatchedWithCallGraph; } +void YAMLProfileReader::InlineTreeNodeMapTy::matchInlineTrees( +const MCPseudoProbeDecoder &Decoder, +const yaml::bolt::PseudoProbeDesc &YamlPD, +

[llvm-branch-commits] [llvm] [BOLT] Match blocks with pseudo probes (PR #99891)

2024-09-18 Thread Lei Wang via llvm-branch-commits
@@ -96,6 +101,42 @@ class YAMLProfileReader : public ProfileReaderBase { YamlBFAdjacencyMap; }; + // A class for matching inline tree nodes between profile and binary. + class InlineTreeNodeMapTy { +DenseMap Map; + +void mapInlineTreeNode(uint32_t ProfileNo

[llvm-branch-commits] [llvm] [BOLT] Match blocks with pseudo probes (PR #99891)

2024-09-18 Thread Lei Wang via llvm-branch-commits
@@ -96,6 +101,42 @@ class YAMLProfileReader : public ProfileReaderBase { YamlBFAdjacencyMap; }; + // A class for matching inline tree nodes between profile and binary. + class InlineTreeNodeMapTy { +DenseMap Map; wlei-llvm wrote: add comments

[llvm-branch-commits] [llvm] [BOLT] Match blocks with pseudo probes (PR #99891)

2024-09-18 Thread Lei Wang via llvm-branch-commits
@@ -266,6 +305,69 @@ class StaleMatcher { } return BestBlock; } + + /// Matches a profile block with an binary block based on pseudo probes. wlei-llvm wrote: nit: `an` -> `a` https://github.com/llvm/llvm-project/pull/99891 _

[llvm-branch-commits] [llvm] [BOLT] Match blocks with pseudo probes (PR #99891)

2024-09-18 Thread Lei Wang via llvm-branch-commits
@@ -96,6 +101,42 @@ class YAMLProfileReader : public ProfileReaderBase { YamlBFAdjacencyMap; }; + // A class for matching inline tree nodes between profile and binary. + class InlineTreeNodeMapTy { +DenseMap Map; + +void mapInlineTreeNode(uint32_t ProfileNo

[llvm-branch-commits] [llvm] [BOLT] Match blocks with pseudo probes (PR #99891)

2024-09-18 Thread Lei Wang via llvm-branch-commits
@@ -96,6 +101,42 @@ class YAMLProfileReader : public ProfileReaderBase { YamlBFAdjacencyMap; }; + // A class for matching inline tree nodes between profile and binary. + class InlineTreeNodeMapTy { +DenseMap Map; + +void mapInlineTreeNode(uint32_t ProfileNo

[llvm-branch-commits] [llvm] [BOLT] Match blocks with pseudo probes (PR #99891)

2024-09-18 Thread Lei Wang via llvm-branch-commits
@@ -0,0 +1,62 @@ +## Tests stale block matching with pseudo probes. + +# REQUIRES: system-linux +# RUN: split-file %s %t +# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %t/main.s -o %t.o +# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -nostdlib +# RUN: llvm-bolt %t.exe -

[llvm-branch-commits] [llvm] [BOLT] Match blocks with pseudo probes (PR #99891)

2024-09-18 Thread Lei Wang via llvm-branch-commits
@@ -722,12 +722,28 @@ class BinaryContext { /// Stats for stale profile matching: /// the total number of basic blocks in the profile uint32_t NumStaleBlocks{0}; -/// the number of matched basic blocks -uint32_t NumMatchedBlocks{0}; +/// the number

[llvm-branch-commits] [llvm] [BOLT] Match blocks with pseudo probes (PR #99891)

2024-09-18 Thread Lei Wang via llvm-branch-commits
@@ -587,6 +590,51 @@ size_t YAMLProfileReader::matchWithCallGraph(BinaryContext &BC) { return MatchedWithCallGraph; } +void YAMLProfileReader::InlineTreeNodeMapTy::matchInlineTrees( +const MCPseudoProbeDecoder &Decoder, +const yaml::bolt::PseudoProbeDesc &YamlPD, +

[llvm-branch-commits] [llvm] [BOLT] Match blocks with pseudo probes (PR #99891)

2024-09-18 Thread Lei Wang via llvm-branch-commits
@@ -266,6 +305,69 @@ class StaleMatcher { } return BestBlock; } + + /// Matches a profile block with an binary block based on pseudo probes. + /// Returns the best matching block (or nullptr) and whether the match is + /// unambiguous. + std::pair matchWithPseudoP

[llvm-branch-commits] [llvm] [BOLT] Match blocks with pseudo probes (PR #99891)

2024-09-18 Thread Lei Wang via llvm-branch-commits
@@ -722,6 +770,15 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { } } + if (opts::StaleMatchingWithPseudoProbes) { +const MCPseudoProbeDecoder *Decoder = BC.getPseudoProbeDecoder(); +assert(Decoder && + "If pseudo probes are in use, pseudo

[llvm-branch-commits] [llvm] [BOLT] Match blocks with pseudo probes (PR #99891)

2024-09-18 Thread Lei Wang via llvm-branch-commits
@@ -587,6 +590,51 @@ size_t YAMLProfileReader::matchWithCallGraph(BinaryContext &BC) { return MatchedWithCallGraph; } +void YAMLProfileReader::InlineTreeNodeMapTy::matchInlineTrees( +const MCPseudoProbeDecoder &Decoder, +const yaml::bolt::PseudoProbeDesc &YamlPD, +

[llvm-branch-commits] [llvm] [BOLT] Match blocks with pseudo probes (PR #99891)

2024-09-18 Thread Lei Wang via llvm-branch-commits
@@ -482,6 +584,30 @@ matchWeightsByHashes(BinaryContext &BC, << Twine::utohexstr(BB->getHash()) << "\n"); } StaleMatcher Matcher; + // Collects function pseudo probes for use in the StaleMatcher. + if (opts::StaleMatchingWithPseudoProbes) { +cons

[llvm-branch-commits] [llvm] [BOLT] Add pseudo probe inline tree to YAML profile (PR #107137)

2024-09-12 Thread Lei Wang via llvm-branch-commits
https://github.com/wlei-llvm approved this pull request. LGTM, thanks! https://github.com/llvm/llvm-project/pull/107137 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-

[llvm-branch-commits] [llvm] [BOLT] Add pseudo probe inline tree to YAML profile (PR #107137)

2024-09-12 Thread Lei Wang via llvm-branch-commits
@@ -2421,11 +2433,14 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC, const uint32_t InputOffset = BAT->translate( FuncAddr, OutputAddress - FuncAddr, /*IsBranchSrc=*/true); const unsigned BlockIndex = getBlock(InputOff

[llvm-branch-commits] [llvm] [BOLT] Add pseudo probe inline tree to YAML profile (PR #107137)

2024-09-12 Thread Lei Wang via llvm-branch-commits
@@ -14,29 +14,31 @@ # RUN: FileCheck --input-file %t.yaml2 %s --check-prefix CHECK-YAML # CHECK-YAML: name: bar # CHECK-YAML: - bid: 0 -# CHECK-YAML: pseudo_probes: [ { guid: 0xE413754A191DB537, id: 1, type: 0 }, { guid: 0xE413754A191DB537, id: 4, type: 0 } ] -# CHECK-YAML:

[llvm-branch-commits] [llvm] [BOLT] Add pseudo probe inline tree to YAML profile (PR #107137)

2024-09-12 Thread Lei Wang via llvm-branch-commits
@@ -58,8 +59,158 @@ const BinaryFunction *YAMLProfileWriter::setCSIDestination( return nullptr; } +std::vector +YAMLProfileWriter::collectInlineTree( +const MCPseudoProbeDecoder &Decoder, +const MCDecodedPseudoProbeInlineTree &Root) { + auto getHash = [&](const MCDe

[llvm-branch-commits] [llvm] [BOLT] Add pseudo probe inline tree to YAML profile (PR #107137)

2024-09-11 Thread Lei Wang via llvm-branch-commits
@@ -158,15 +164,35 @@ template <> struct MappingTraits { std::vector()); YamlIO.mapOptional("succ", BBP.Successors, std::vector()); -YamlIO.mapOptional("pseudo_probes", BBP.PseudoProbes, +YamlIO.mapOptional("probes", BB

[llvm-branch-commits] [llvm] [BOLT] Add pseudo probe inline tree to YAML profile (PR #107137)

2024-09-11 Thread Lei Wang via llvm-branch-commits
@@ -158,15 +164,35 @@ template <> struct MappingTraits { std::vector()); YamlIO.mapOptional("succ", BBP.Successors, std::vector()); -YamlIO.mapOptional("pseudo_probes", BBP.PseudoProbes, +YamlIO.mapOptional("probes", BB

[llvm-branch-commits] [llvm] [BOLT] Add pseudo probe inline tree to YAML profile (PR #107137)

2024-09-11 Thread Lei Wang via llvm-branch-commits
@@ -95,24 +95,30 @@ template <> struct MappingTraits { namespace bolt { struct PseudoProbeInfo { - llvm::yaml::Hex64 GUID; - uint64_t Index; - uint8_t Type; + uint32_t InlineTreeIndex = 0; + uint64_t BlockMask = 0; // bitset with probe indices + // Assume BlockMask == 1

[llvm-branch-commits] [llvm] [BOLT] Add pseudo probe inline tree to YAML profile (PR #107137)

2024-09-11 Thread Lei Wang via llvm-branch-commits
@@ -95,24 +95,30 @@ template <> struct MappingTraits { namespace bolt { struct PseudoProbeInfo { - llvm::yaml::Hex64 GUID; - uint64_t Index; - uint8_t Type; + uint32_t InlineTreeIndex = 0; + uint64_t BlockMask = 0; // bitset with probe indices wlei-llvm w

[llvm-branch-commits] [llvm] [BOLT] Add pseudo probe inline tree to YAML profile (PR #107137)

2024-09-11 Thread Lei Wang via llvm-branch-commits
@@ -58,8 +60,164 @@ const BinaryFunction *YAMLProfileWriter::setCSIDestination( return nullptr; } +std::vector +YAMLProfileWriter::getInlineTree(const MCPseudoProbeDecoder &Decoder, wlei-llvm wrote: Is it possible to give a more explicit name? when I saw th

[llvm-branch-commits] [llvm] [BOLT] Add pseudo probe inline tree to YAML profile (PR #107137)

2024-09-11 Thread Lei Wang via llvm-branch-commits
@@ -58,8 +60,164 @@ const BinaryFunction *YAMLProfileWriter::setCSIDestination( return nullptr; } +std::vector +YAMLProfileWriter::getInlineTree(const MCPseudoProbeDecoder &Decoder, + const MCDecodedPseudoProbeInlineTree *Root) { + auto getHa

[llvm-branch-commits] [llvm] [BOLT] Add pseudo probe inline tree to YAML profile (PR #107137)

2024-09-11 Thread Lei Wang via llvm-branch-commits
@@ -95,24 +95,30 @@ template <> struct MappingTraits { namespace bolt { struct PseudoProbeInfo { - llvm::yaml::Hex64 GUID; - uint64_t Index; - uint8_t Type; + uint32_t InlineTreeIndex = 0; + uint64_t BlockMask = 0; // bitset with probe indices + // Assume BlockMask == 1

[llvm-branch-commits] [llvm] [BOLT] Add pseudo probe inline tree to YAML profile (PR #107137)

2024-09-11 Thread Lei Wang via llvm-branch-commits
@@ -58,8 +60,164 @@ const BinaryFunction *YAMLProfileWriter::setCSIDestination( return nullptr; } +std::vector +YAMLProfileWriter::getInlineTree(const MCPseudoProbeDecoder &Decoder, + const MCDecodedPseudoProbeInlineTree *Root) { + auto getHa

[llvm-branch-commits] [llvm] [BOLT] Add pseudo probe inline tree to YAML profile (PR #107137)

2024-09-11 Thread Lei Wang via llvm-branch-commits
@@ -2421,11 +2433,14 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC, const uint32_t InputOffset = BAT->translate( FuncAddr, OutputAddress - FuncAddr, /*IsBranchSrc=*/true); const unsigned BlockIndex = getBlock(InputOff

[llvm-branch-commits] [llvm] [BOLT] Add pseudo probe inline tree to YAML profile (PR #107137)

2024-09-11 Thread Lei Wang via llvm-branch-commits
@@ -246,10 +270,32 @@ template <> struct MappingTraits { } }; +namespace bolt { +struct PseudoProbeDesc { + std::vector GUID; + std::vector Hash; + std::vector GUIDHash; // Index of hash for that GUID in Hash wlei-llvm wrote: Give another name? IIUC, it

[llvm-branch-commits] [llvm] [BOLT] Add pseudo probe inline tree to YAML profile (PR #107137)

2024-09-11 Thread Lei Wang via llvm-branch-commits
@@ -58,8 +60,164 @@ const BinaryFunction *YAMLProfileWriter::setCSIDestination( return nullptr; } +std::vector +YAMLProfileWriter::getInlineTree(const MCPseudoProbeDecoder &Decoder, + const MCDecodedPseudoProbeInlineTree *Root) { + auto getHa

[llvm-branch-commits] [BOLT] Only parse probes for profiled functions in profile-write-pseudo-probes mode (PR #106365)

2024-08-28 Thread Lei Wang via llvm-branch-commits
https://github.com/wlei-llvm approved this pull request. LGTM, thanks. https://github.com/llvm/llvm-project/pull/106365 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-

[llvm-branch-commits] [llvm] [MC][NFC] Reduce Address2ProbesMap size (PR #102904)

2024-08-22 Thread Lei Wang via llvm-branch-commits
https://github.com/wlei-llvm approved this pull request. https://github.com/llvm/llvm-project/pull/102904 ___ 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] [MC][NFC] Use vector for GUIDProbeFunctionMap (PR #102905)

2024-08-22 Thread Lei Wang via llvm-branch-commits
https://github.com/wlei-llvm approved this pull request. LGTM, thanks. https://github.com/llvm/llvm-project/pull/102905 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-

[llvm-branch-commits] [llvm] [MC][NFC] Statically allocate storage for decoded pseudo probes and function records (PR #102789)

2024-08-22 Thread Lei Wang via llvm-branch-commits
https://github.com/wlei-llvm approved this pull request. LGTM, thanks. https://github.com/llvm/llvm-project/pull/102789 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-

[llvm-branch-commits] [llvm] [MC][NFC] Reduce Address2ProbesMap size (PR #102904)

2024-08-20 Thread Lei Wang via llvm-branch-commits
wlei-llvm wrote: > > To double-check: did you test with or without dwarf-correlation? I tested > > once with it, expectedly pseudo probe parsing wasn't engaged, so there was > > no effect. > > Yes, I double-checked it's a pseudo-probed binary not dwarf-correlation. Note > that for end to end

[llvm-branch-commits] [llvm] [MC][NFC] Reduce Address2ProbesMap size (PR #102904)

2024-08-20 Thread Lei Wang via llvm-branch-commits
wlei-llvm wrote: > > Tested End-to-End on llvm-profgen on a heavy workload(ported all the > > stacked PR) : The running time is neutral, the maximum RSS is reduced by > > 3GB (from 70GB to 67GB) cc @WenleiHe > > To double-check: did you test with or without dwarf-correlation? I tested > onc

[llvm-branch-commits] [llvm] [MC][NFC] Reduce Address2ProbesMap size (PR #102904)

2024-08-19 Thread Lei Wang via llvm-branch-commits
https://github.com/wlei-llvm commented: Tested End-to-End on llvm-profgen on a heavy workload(ported all the stacked PR) : The running time is neutral, the maximum RSS is reduced by 3GB (from 70GB to 67GB) cc @WenleiHe https://github.com/llvm/llvm-project/pull/102904 __

[llvm-branch-commits] [llvm] [MC][NFC] Reduce Address2ProbesMap size (PR #102904)

2024-08-19 Thread Lei Wang via llvm-branch-commits
@@ -213,6 +208,33 @@ class MCDecodedPseudoProbe : public MCPseudoProbeBase { bool ShowName) const; }; +// Address to pseudo probes map. +class AddressProbesMap +: public std::vector> { + auto getIt(uint64_t Addr) const { +auto CompareProbe = [](const MCDe

[llvm-branch-commits] [llvm] [MC][NFC] Reduce Address2ProbesMap size (PR #102904)

2024-08-19 Thread Lei Wang via llvm-branch-commits
https://github.com/wlei-llvm edited https://github.com/llvm/llvm-project/pull/102904 ___ 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] [MC][NFC] Reduce Address2ProbesMap size (PR #102904)

2024-08-16 Thread Lei Wang via llvm-branch-commits
@@ -213,6 +208,31 @@ class MCDecodedPseudoProbe : public MCPseudoProbeBase { bool ShowName) const; }; +// Address to pseudo probes map. +class AddressProbesMap +: public std::vector> { + auto getIt(uint64_t Addr) const { +auto CompareProbe = [](const MCDe

[llvm-branch-commits] [MC][NFC] Use vector for GUIDProbeFunctionMap (PR #102905)

2024-08-15 Thread Lei Wang via llvm-branch-commits
@@ -100,8 +101,15 @@ class MCDecodedPseudoProbe; using InlineSite = std::tuple; using MCPseudoProbeInlineStack = SmallVector; // GUID to PseudoProbeFuncDesc map -using GUIDProbeFunctionMap = -std::unordered_map; +class GUIDProbeFunctionMap : public std::vector { +public: +

[llvm-branch-commits] [MC][NFC] Use vector for GUIDProbeFunctionMap (PR #102905)

2024-08-15 Thread Lei Wang via llvm-branch-commits
@@ -390,32 +390,41 @@ bool MCPseudoProbeDecoder::buildGUID2FuncDescMap(const uint8_t *Start, Data = Start; End = Data + Size; + uint32_t FuncDescCount = 0; while (Data < End) { -auto ErrorOrGUID = readUnencodedNumber(); -if (!ErrorOrGUID) +if (!readUnencod

[llvm-branch-commits] [MC][NFC] Use vector for GUIDProbeFunctionMap (PR #102905)

2024-08-15 Thread Lei Wang via llvm-branch-commits
@@ -390,32 +390,41 @@ bool MCPseudoProbeDecoder::buildGUID2FuncDescMap(const uint8_t *Start, Data = Start; End = Data + Size; + uint32_t FuncDescCount = 0; while (Data < End) { -auto ErrorOrGUID = readUnencodedNumber(); -if (!ErrorOrGUID) +if (!readUnencod

[llvm-branch-commits] [llvm] [MC][NFC] Reduce Address2ProbesMap size (PR #102904)

2024-08-15 Thread Lei Wang via llvm-branch-commits
@@ -213,6 +208,25 @@ class MCDecodedPseudoProbe : public MCPseudoProbeBase { bool ShowName) const; }; +// Address to pseudo probes map. +class AddressProbesMap +: public std::vector> { + auto getIt(uint64_t Addr) const { +auto CompareProbe = [](const MCDe

[llvm-branch-commits] [llvm] [MC][NFC] Reduce Address2ProbesMap size (PR #102904)

2024-08-15 Thread Lei Wang via llvm-branch-commits
@@ -1183,11 +1183,9 @@ void ProfileGeneratorBase::extractProbesFromRange( do { const AddressProbesMap &Address2ProbesMap = Binary->getAddress2ProbesMap(); - auto It = Address2ProbesMap.find(IP.Address); - if (It != Address2ProbesMap.end()) { -

[llvm-branch-commits] [llvm] [MC][NFC] Reduce Address2ProbesMap size (PR #102904)

2024-08-15 Thread Lei Wang via llvm-branch-commits
@@ -213,6 +208,25 @@ class MCDecodedPseudoProbe : public MCPseudoProbeBase { bool ShowName) const; }; +// Address to pseudo probes map. +class AddressProbesMap +: public std::vector> { + auto getIt(uint64_t Addr) const { +auto CompareProbe = [](const MCDe

[llvm-branch-commits] [llvm] [MC][NFC] Statically allocate storage for decoded pseudo probes and function records (PR #102789)

2024-08-15 Thread Lei Wang via llvm-branch-commits
@@ -1293,9 +1293,9 @@ void CSProfileGenerator::populateBodySamplesWithProbes( // and will be inferred by the compiler. for (auto &I : FrameSamples) { for (auto *FunctionProfile : I.second) { - for (auto *Probe : I.first->getProbes()) { -FunctionProfile->add

[llvm-branch-commits] [llvm] [MC][NFC] Statically allocate storage for decoded pseudo probes and function records (PR #102789)

2024-08-15 Thread Lei Wang via llvm-branch-commits
@@ -240,12 +235,11 @@ class MCPseudoProbeInlineTreeBase { bool isRoot() const { return Guid == 0; } InlinedProbeTreeMap &getChildren() { return Children; } const InlinedProbeTreeMap &getChildren() const { return Children; } - std::vector &getProbes() { return Probes; } -

[llvm-branch-commits] [llvm] [MC][NFC] Statically allocate storage for decoded pseudo probes and function records (PR #102789)

2024-08-15 Thread Lei Wang via llvm-branch-commits
@@ -605,13 +616,20 @@ bool MCPseudoProbeDecoder::buildAddress2ProbeMap( TopLevelFuncs += !Discard; } assert(Data == End && "Have unprocessed data in pseudo_probe section"); + PseudoProbeVec.reserve(ProbeCount); + InlineTreeVec.reserve(InlinedCount); w

[llvm-branch-commits] [llvm] [MC][NFC] Statically allocate storage for decoded pseudo probes and function records (PR #102789)

2024-08-14 Thread Lei Wang via llvm-branch-commits
wlei-llvm wrote: Measured `decode_pseudo_probe(llvm-profgen)` on a large binary with 1.7GB `.pseudo_probe` section Ported and used all the improvements in a whole. Before those changes: ``` Time: 190s , RSS: 57.4GB ``` After those changes: ``` Time: 55s , RSS: 26.3GB ``` Awesome! https://git

[llvm-branch-commits] [llvm] [MC][NFC] Statically allocate storage for decoded pseudo probes and function records (PR #102789)

2024-08-13 Thread Lei Wang via llvm-branch-commits
https://github.com/wlei-llvm commented: Thanks for the improvement, I will try it on llvm-profgen to get some numbers. https://github.com/llvm/llvm-project/pull/102789 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://list

[llvm-branch-commits] [llvm] [MC][NFC] Statically allocate storage for decoded pseudo probes and function records (PR #102789)

2024-08-13 Thread Lei Wang via llvm-branch-commits
@@ -276,17 +278,35 @@ class MCPseudoProbeInlineTree }; // inline tree node for the decoded pseudo probe -class MCDecodedPseudoProbeInlineTree -: public MCPseudoProbeInlineTreeBase { +class MCDecodedPseudoProbeInlineTree { wlei-llvm wrote: Now that this cl

[llvm-branch-commits] [llvm] [MC][NFC] Statically allocate storage for decoded pseudo probes and function records (PR #102789)

2024-08-13 Thread Lei Wang via llvm-branch-commits
@@ -218,9 +220,7 @@ void PseudoProbeRewriter::updatePseudoProbes() { } while (CallOutputAddress != CallOutputAddresses.second) { - AP.second.push_back(*Probe); - AP.second.back().setAddress(CallOutputAddress->second); - Probe->getInli

[llvm-branch-commits] [llvm] [MC][NFC] Statically allocate storage for decoded pseudo probes and function records (PR #102789)

2024-08-13 Thread Lei Wang via llvm-branch-commits
https://github.com/wlei-llvm edited https://github.com/llvm/llvm-project/pull/102789 ___ 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] [MC][profgen][NFC] Expand auto for MCDecodedPseudoProbe (PR #102788)

2024-08-10 Thread Lei Wang via llvm-branch-commits
https://github.com/wlei-llvm approved this pull request. https://github.com/llvm/llvm-project/pull/102788 ___ 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] Add profile density computation (PR #101094)

2024-08-09 Thread Lei Wang via llvm-branch-commits
@@ -1441,6 +1458,22 @@ Error PrintProgramStats::runOnFunctions(BinaryContext &BC) { StaleSampleCount += SampleCount; ++NumAllStaleFunctions; } + +if (opts::ShowDensity) { + uint64_t Size = Function.getSize(); + // In case of BOLT split functions r

[llvm-branch-commits] [llvm] [BOLT] Add profile density computation (PR #101094)

2024-08-09 Thread Lei Wang via llvm-branch-commits
@@ -1441,6 +1458,22 @@ Error PrintProgramStats::runOnFunctions(BinaryContext &BC) { StaleSampleCount += SampleCount; ++NumAllStaleFunctions; } + +if (opts::ShowDensity) { + uint64_t Size = Function.getSize(); + // In case of BOLT split functions r

[llvm-branch-commits] [llvm] [BOLT] Add profile density computation (PR #101094)

2024-07-29 Thread Lei Wang via llvm-branch-commits
@@ -223,6 +223,22 @@ static cl::opt TopCalledLimit( "functions section"), cl::init(100), cl::Hidden, cl::cat(BoltCategory)); +// Profile density options, synced with llvm-profgen/ProfileGenerator.cpp +static cl::opt ShowDensity("show-density", cl::init(false),

[llvm-branch-commits] [llvm] [BOLT] Match blocks with pseudo probes (PR #99891)

2024-07-26 Thread Lei Wang via llvm-branch-commits
https://github.com/wlei-llvm deleted https://github.com/llvm/llvm-project/pull/99891 ___ 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] Match blocks with pseudo probes (PR #99891)

2024-07-25 Thread Lei Wang via llvm-branch-commits
@@ -478,10 +675,34 @@ matchWeightsByHashes(BinaryContext &BC, Blocks.push_back(&Func.Blocks[I + 1]); BlendedBlockHash BlendedHash(BB->getHash()); BlendedHashes.push_back(BlendedHash); +// Collects pseudo probes attached to the BB for use in the StaleMatcher. +

[llvm-branch-commits] [llvm] [BOLT] Match blocks with pseudo probes (PR #99891)

2024-07-25 Thread Lei Wang via llvm-branch-commits
@@ -266,6 +325,122 @@ class StaleMatcher { } return BestBlock; } + + /// A helper function for logging. + static bool LogErrIfExpr(bool Expr, StringRef Message) { +if (Expr) + errs() << Message; +return Expr; + } + + /// Matches an inlined profile blo

[llvm-branch-commits] [llvm] [BOLT] Match blocks with pseudo probes (PR #99891)

2024-07-25 Thread Lei Wang via llvm-branch-commits
@@ -266,6 +325,122 @@ class StaleMatcher { } return BestBlock; } + + /// A helper function for logging. + static bool LogErrIfExpr(bool Expr, StringRef Message) { +if (Expr) + errs() << Message; +return Expr; + } + + /// Matches an inlined profile blo

[llvm-branch-commits] [llvm] [BOLT] Match blocks with pseudo probes (PR #99891)

2024-07-25 Thread Lei Wang via llvm-branch-commits
@@ -266,6 +325,123 @@ class StaleMatcher { } return BestBlock; } + + /// A helper function for logging. + static bool LogErrIfExpr(bool Expr, std::string Message) { wlei-llvm wrote: Nit: `std::string` can this be `StringRef`? https://github.com/ll

[llvm-branch-commits] [llvm] [BOLT] Match blocks with pseudo probes (PR #99891)

2024-07-25 Thread Lei Wang via llvm-branch-commits
@@ -116,6 +118,11 @@ cl::opt StaleMatchingCostJumpUnknownFTInc( "The cost of increasing an unknown fall-through jump count by one."), cl::init(3), cl::ReallyHidden, cl::cat(BoltOptCategory)); +cl::opt StaleMatchingWithBlockPseudoProbes( +"stale-matching-with-bl

[llvm-branch-commits] [llvm] [BOLT] Match blocks with pseudo probes (PR #99891)

2024-07-25 Thread Lei Wang via llvm-branch-commits
@@ -0,0 +1,62 @@ +## Tests stale block matching with pseudo probes. + +# REQUIRES: system-linux +# RUN: split-file %s %t +# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %t/main.s -o %t.o +# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -nostdlib +# RUN: llvm-bolt %t.exe -

[llvm-branch-commits] [llvm] [BOLT] Match blocks with pseudo probes (PR #99891)

2024-07-25 Thread Lei Wang via llvm-branch-commits
@@ -478,10 +675,34 @@ matchWeightsByHashes(BinaryContext &BC, Blocks.push_back(&Func.Blocks[I + 1]); BlendedBlockHash BlendedHash(BB->getHash()); BlendedHashes.push_back(BlendedHash); +// Collects pseudo probes attached to the BB for use in the StaleMatcher. +

[llvm-branch-commits] [MC][NFC] Use std::map for AddressProbesMap (PR #99553)

2024-07-18 Thread Lei Wang via llvm-branch-commits
https://github.com/wlei-llvm approved this pull request. LGTM. https://github.com/llvm/llvm-project/pull/99553 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits