[llvm-branch-commits] [llvm] [BOLT] Output basic YAML profile in BAT mode (PR #76910)
https://github.com/aaupov edited https://github.com/llvm/llvm-project/pull/76910 ___ 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] Output basic YAML profile in BAT mode (PR #76910)
https://github.com/aaupov edited https://github.com/llvm/llvm-project/pull/76910 ___ 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] Add BB index to BAT (PR #86044)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/86044 ___ 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] Add BB index to BAT (PR #86044)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/86044 ___ 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] Add BB index to BAT (PR #86044)
https://github.com/aaupov edited https://github.com/llvm/llvm-project/pull/86044 ___ 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 BB index to BAT (PR #86044)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/86044 >From 2a97ba165c6e5689cdd8c4208d35e042760e7444 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Thu, 21 Mar 2024 14:54:23 -0700 Subject: [PATCH] cleanup Created using spr 1.3.4 --- bolt/lib/Profile/BoltAddressTranslation.cpp | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bolt/lib/Profile/BoltAddressTranslation.cpp b/bolt/lib/Profile/BoltAddressTranslation.cpp index 03769d127bf6e6..8fe976cc00e53c 100644 --- a/bolt/lib/Profile/BoltAddressTranslation.cpp +++ b/bolt/lib/Profile/BoltAddressTranslation.cpp @@ -513,6 +513,11 @@ void BoltAddressTranslation::saveMetadata(BinaryContext &BC) { } } +unsigned BoltAddressTranslation::getBBIndex(uint64_t FuncOutputAddress, +uint32_t BBInputOffset) const { + return FuncHashes.at(FuncOutputAddress).second.at(BBInputOffset).first; +} + size_t BoltAddressTranslation::getBBHash(uint64_t FuncOutputAddress, uint32_t BBInputOffset) const { return FuncHashes.at(FuncOutputAddress).second.at(BBInputOffset).second; @@ -522,10 +527,5 @@ size_t BoltAddressTranslation::getBFHash(uint64_t OutputAddress) const { return FuncHashes.at(OutputAddress).first; } -unsigned BoltAddressTranslation::getBBIndex(uint64_t FuncOutputAddress, -uint32_t BBInputOffset) const { - return FuncHashes.at(FuncOutputAddress).second.at(BBInputOffset).first; -} - } // namespace bolt } // namespace llvm ___ 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] Add secondary entry points to BAT (PR #86218)
https://github.com/aaupov created https://github.com/llvm/llvm-project/pull/86218 Provide secondary entry points for `EntryDiscriminator` call info field in YAML profile. Increases BAT section size to: - large binary: 39655300 bytes (1.03x the original), - medium binary: 3834328 bytes (0.65x), - small binary: 924 bytes (0.64x). Test Plan: Updated bolt-address-translation{,-yaml}.test ___ 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 BAT callbacks in YAMLProfileWriter::convert (PR #86219)
https://github.com/aaupov created https://github.com/llvm/llvm-project/pull/86219 Test Plan: TBD ___ 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 BB index to BAT (PR #86044)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/86044 >From 2a97ba165c6e5689cdd8c4208d35e042760e7444 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Thu, 21 Mar 2024 14:54:23 -0700 Subject: [PATCH] cleanup Created using spr 1.3.4 --- bolt/lib/Profile/BoltAddressTranslation.cpp | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bolt/lib/Profile/BoltAddressTranslation.cpp b/bolt/lib/Profile/BoltAddressTranslation.cpp index 03769d127bf6e6..8fe976cc00e53c 100644 --- a/bolt/lib/Profile/BoltAddressTranslation.cpp +++ b/bolt/lib/Profile/BoltAddressTranslation.cpp @@ -513,6 +513,11 @@ void BoltAddressTranslation::saveMetadata(BinaryContext &BC) { } } +unsigned BoltAddressTranslation::getBBIndex(uint64_t FuncOutputAddress, +uint32_t BBInputOffset) const { + return FuncHashes.at(FuncOutputAddress).second.at(BBInputOffset).first; +} + size_t BoltAddressTranslation::getBBHash(uint64_t FuncOutputAddress, uint32_t BBInputOffset) const { return FuncHashes.at(FuncOutputAddress).second.at(BBInputOffset).second; @@ -522,10 +527,5 @@ size_t BoltAddressTranslation::getBFHash(uint64_t OutputAddress) const { return FuncHashes.at(OutputAddress).first; } -unsigned BoltAddressTranslation::getBBIndex(uint64_t FuncOutputAddress, -uint32_t BBInputOffset) const { - return FuncHashes.at(FuncOutputAddress).second.at(BBInputOffset).first; -} - } // namespace bolt } // namespace llvm ___ 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 BB index to BAT (PR #86044)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/86044 >From 2a97ba165c6e5689cdd8c4208d35e042760e7444 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Thu, 21 Mar 2024 14:54:23 -0700 Subject: [PATCH] cleanup Created using spr 1.3.4 --- bolt/lib/Profile/BoltAddressTranslation.cpp | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bolt/lib/Profile/BoltAddressTranslation.cpp b/bolt/lib/Profile/BoltAddressTranslation.cpp index 03769d127bf6e6..8fe976cc00e53c 100644 --- a/bolt/lib/Profile/BoltAddressTranslation.cpp +++ b/bolt/lib/Profile/BoltAddressTranslation.cpp @@ -513,6 +513,11 @@ void BoltAddressTranslation::saveMetadata(BinaryContext &BC) { } } +unsigned BoltAddressTranslation::getBBIndex(uint64_t FuncOutputAddress, +uint32_t BBInputOffset) const { + return FuncHashes.at(FuncOutputAddress).second.at(BBInputOffset).first; +} + size_t BoltAddressTranslation::getBBHash(uint64_t FuncOutputAddress, uint32_t BBInputOffset) const { return FuncHashes.at(FuncOutputAddress).second.at(BBInputOffset).second; @@ -522,10 +527,5 @@ size_t BoltAddressTranslation::getBFHash(uint64_t OutputAddress) const { return FuncHashes.at(OutputAddress).first; } -unsigned BoltAddressTranslation::getBBIndex(uint64_t FuncOutputAddress, -uint32_t BBInputOffset) const { - return FuncHashes.at(FuncOutputAddress).second.at(BBInputOffset).first; -} - } // namespace bolt } // namespace llvm ___ 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] Add number of basic blocks to BAT (PR #86045)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/86045 ___ 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] Add number of basic blocks to BAT (PR #86045)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/86045 ___ 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] Emit intra-function control flow in YAMLBAT (PR #76911)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/76911 ___ 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] Emit intra-function control flow in YAMLBAT (PR #76911)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/76911 ___ 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] Set EntryDiscriminator in YAML profile for indirect calls (PR #82128)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/82128 ___ 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] Set EntryDiscriminator in YAML profile for indirect calls (PR #82128)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/82128 ___ 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 CallSiteInfo entries in YAMLBAT (PR #76896)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/76896 >From 3362e9990ee0334ab7073943b4b682764f52bc8f Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Thu, 4 Jan 2024 10:40:04 -0800 Subject: [PATCH] Assert that a function exists Created using spr 1.3.4 --- bolt/lib/Profile/BoltAddressTranslation.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bolt/lib/Profile/BoltAddressTranslation.cpp b/bolt/lib/Profile/BoltAddressTranslation.cpp index dbc9e1702a3016..62f8b777ee91b4 100644 --- a/bolt/lib/Profile/BoltAddressTranslation.cpp +++ b/bolt/lib/Profile/BoltAddressTranslation.cpp @@ -521,8 +521,7 @@ std::unordered_map> BoltAddressTranslation::getBFBranches(uint64_t OutputAddress) const { std::unordered_map> Branches; auto FuncIt = Maps.find(OutputAddress); - if (FuncIt == Maps.end()) -return Branches; + assert(FuncIt != Maps.end()); std::vector InputOffsets; for (const auto &KV : FuncIt->second) InputOffsets.emplace_back(KV.second); ___ 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 CallSiteInfo entries in YAMLBAT (PR #76896)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/76896 >From 3362e9990ee0334ab7073943b4b682764f52bc8f Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Thu, 4 Jan 2024 10:40:04 -0800 Subject: [PATCH] Assert that a function exists Created using spr 1.3.4 --- bolt/lib/Profile/BoltAddressTranslation.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bolt/lib/Profile/BoltAddressTranslation.cpp b/bolt/lib/Profile/BoltAddressTranslation.cpp index dbc9e1702a3016..62f8b777ee91b4 100644 --- a/bolt/lib/Profile/BoltAddressTranslation.cpp +++ b/bolt/lib/Profile/BoltAddressTranslation.cpp @@ -521,8 +521,7 @@ std::unordered_map> BoltAddressTranslation::getBFBranches(uint64_t OutputAddress) const { std::unordered_map> Branches; auto FuncIt = Maps.find(OutputAddress); - if (FuncIt == Maps.end()) -return Branches; + assert(FuncIt != Maps.end()); std::vector InputOffsets; for (const auto &KV : FuncIt->second) InputOffsets.emplace_back(KV.second); ___ 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 BB index to BAT (PR #86044)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/86044 >From 2a97ba165c6e5689cdd8c4208d35e042760e7444 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Thu, 21 Mar 2024 14:54:23 -0700 Subject: [PATCH] cleanup Created using spr 1.3.4 --- bolt/lib/Profile/BoltAddressTranslation.cpp | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bolt/lib/Profile/BoltAddressTranslation.cpp b/bolt/lib/Profile/BoltAddressTranslation.cpp index 03769d127bf6e6..8fe976cc00e53c 100644 --- a/bolt/lib/Profile/BoltAddressTranslation.cpp +++ b/bolt/lib/Profile/BoltAddressTranslation.cpp @@ -513,6 +513,11 @@ void BoltAddressTranslation::saveMetadata(BinaryContext &BC) { } } +unsigned BoltAddressTranslation::getBBIndex(uint64_t FuncOutputAddress, +uint32_t BBInputOffset) const { + return FuncHashes.at(FuncOutputAddress).second.at(BBInputOffset).first; +} + size_t BoltAddressTranslation::getBBHash(uint64_t FuncOutputAddress, uint32_t BBInputOffset) const { return FuncHashes.at(FuncOutputAddress).second.at(BBInputOffset).second; @@ -522,10 +527,5 @@ size_t BoltAddressTranslation::getBFHash(uint64_t OutputAddress) const { return FuncHashes.at(OutputAddress).first; } -unsigned BoltAddressTranslation::getBBIndex(uint64_t FuncOutputAddress, -uint32_t BBInputOffset) const { - return FuncHashes.at(FuncOutputAddress).second.at(BBInputOffset).first; -} - } // namespace bolt } // namespace llvm ___ 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 BB index to BAT (PR #86044)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/86044 >From 2a97ba165c6e5689cdd8c4208d35e042760e7444 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Thu, 21 Mar 2024 14:54:23 -0700 Subject: [PATCH] cleanup Created using spr 1.3.4 --- bolt/lib/Profile/BoltAddressTranslation.cpp | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bolt/lib/Profile/BoltAddressTranslation.cpp b/bolt/lib/Profile/BoltAddressTranslation.cpp index 03769d127bf6e6..8fe976cc00e53c 100644 --- a/bolt/lib/Profile/BoltAddressTranslation.cpp +++ b/bolt/lib/Profile/BoltAddressTranslation.cpp @@ -513,6 +513,11 @@ void BoltAddressTranslation::saveMetadata(BinaryContext &BC) { } } +unsigned BoltAddressTranslation::getBBIndex(uint64_t FuncOutputAddress, +uint32_t BBInputOffset) const { + return FuncHashes.at(FuncOutputAddress).second.at(BBInputOffset).first; +} + size_t BoltAddressTranslation::getBBHash(uint64_t FuncOutputAddress, uint32_t BBInputOffset) const { return FuncHashes.at(FuncOutputAddress).second.at(BBInputOffset).second; @@ -522,10 +527,5 @@ size_t BoltAddressTranslation::getBFHash(uint64_t OutputAddress) const { return FuncHashes.at(OutputAddress).first; } -unsigned BoltAddressTranslation::getBBIndex(uint64_t FuncOutputAddress, -uint32_t BBInputOffset) const { - return FuncHashes.at(FuncOutputAddress).second.at(BBInputOffset).first; -} - } // namespace bolt } // namespace llvm ___ 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] Add number of basic blocks to BAT (PR #86045)
https://github.com/aaupov edited https://github.com/llvm/llvm-project/pull/86045 ___ 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] Emit intra-function control flow in YAMLBAT (PR #76911)
@@ -128,6 +128,26 @@ class BoltAddressTranslation { /// Returns BB index by function output address (after BOLT) and basic block /// input offset. unsigned getBBIndex(uint64_t FuncOutputAddress, uint32_t BBInputOffset) const; + + using BBHashMap = std::map>; + /// Return a mapping from basic block input offset to hash and block index for a given function. + const BBHashMap &getBBHashMap(uint64_t OutputAddress) const { +return FuncHashes.at(OutputAddress).second; aaupov wrote: Thanks for pointing out. You're right, it does throw an exception: https://en.cppreference.com/w/cpp/container/map/at I had code with `find` and `assert` but switched to `at` for conciseness. Let me unwind that. https://github.com/llvm/llvm-project/pull/76911 ___ 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] Emit intra-function control flow in YAMLBAT (PR #76911)
@@ -128,6 +128,26 @@ class BoltAddressTranslation { /// Returns BB index by function output address (after BOLT) and basic block /// input offset. unsigned getBBIndex(uint64_t FuncOutputAddress, uint32_t BBInputOffset) const; + + using BBHashMap = std::map>; + /// Return a mapping from basic block input offset to hash and block index for a given function. + const BBHashMap &getBBHashMap(uint64_t OutputAddress) const { +return FuncHashes.at(OutputAddress).second; aaupov wrote: Addressed in https://github.com/llvm/llvm-project/pull/86353. Will rebase this and follow-up diffs shortly. https://github.com/llvm/llvm-project/pull/76911 ___ 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] Emit intra-function control flow in YAMLBAT (PR #76911)
https://github.com/aaupov edited https://github.com/llvm/llvm-project/pull/76911 ___ 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 BAT callbacks in YAMLProfileWriter::convert (PR #86219)
https://github.com/aaupov edited 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] Add secondary entry points to BAT (PR #86218)
https://github.com/aaupov edited https://github.com/llvm/llvm-project/pull/86218 ___ 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 CallSiteInfo entries in YAMLBAT (PR #76896)
https://github.com/aaupov edited https://github.com/llvm/llvm-project/pull/76896 ___ 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] Emit intra-function control flow in YAMLBAT (PR #76911)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/76911 ___ 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] Emit intra-function control flow in YAMLBAT (PR #76911)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/76911 ___ 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] Add secondary entry points to BAT (PR #86218)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/86218 ___ 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] Add secondary entry points to BAT (PR #86218)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/86218 ___ 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 secondary entry points to BAT (PR #86218)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/86218 >From 6bc606b39044876a883aebc68fc5bbc8699094c5 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Sat, 23 Mar 2024 16:36:36 -0700 Subject: [PATCH] Fix test Created using spr 1.3.4 --- bolt/test/X86/bolt-address-translation-yaml.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bolt/test/X86/bolt-address-translation-yaml.test b/bolt/test/X86/bolt-address-translation-yaml.test index be3bcb2a0c6dd1..306050a1c97e2b 100644 --- a/bolt/test/X86/bolt-address-translation-yaml.test +++ b/bolt/test/X86/bolt-address-translation-yaml.test @@ -18,7 +18,7 @@ RUN: | FileCheck --check-prefix CHECK-BOLT-YAML %s WRITE-BAT-CHECK: BOLT-INFO: Wrote 5 BAT maps WRITE-BAT-CHECK: BOLT-INFO: Wrote 4 function and 22 basic block hashes -WRITE-BAT-CHECK: BOLT-INFO: BAT section size (bytes): 380 +WRITE-BAT-CHECK: BOLT-INFO: BAT section size (bytes): 384 READ-BAT-CHECK-NOT: BOLT-ERROR: unable to save profile in YAML format for input file processed by BOLT READ-BAT-CHECK: BOLT-INFO: Parsed 5 BAT entries ___ 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 secondary entry points to BAT (PR #86218)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/86218 >From 6bc606b39044876a883aebc68fc5bbc8699094c5 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Sat, 23 Mar 2024 16:36:36 -0700 Subject: [PATCH] Fix test Created using spr 1.3.4 --- bolt/test/X86/bolt-address-translation-yaml.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bolt/test/X86/bolt-address-translation-yaml.test b/bolt/test/X86/bolt-address-translation-yaml.test index be3bcb2a0c6dd1..306050a1c97e2b 100644 --- a/bolt/test/X86/bolt-address-translation-yaml.test +++ b/bolt/test/X86/bolt-address-translation-yaml.test @@ -18,7 +18,7 @@ RUN: | FileCheck --check-prefix CHECK-BOLT-YAML %s WRITE-BAT-CHECK: BOLT-INFO: Wrote 5 BAT maps WRITE-BAT-CHECK: BOLT-INFO: Wrote 4 function and 22 basic block hashes -WRITE-BAT-CHECK: BOLT-INFO: BAT section size (bytes): 380 +WRITE-BAT-CHECK: BOLT-INFO: BAT section size (bytes): 384 READ-BAT-CHECK-NOT: BOLT-ERROR: unable to save profile in YAML format for input file processed by BOLT READ-BAT-CHECK: BOLT-INFO: Parsed 5 BAT entries ___ 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 secondary entry points to BAT (PR #86218)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/86218 >From 6bc606b39044876a883aebc68fc5bbc8699094c5 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Sat, 23 Mar 2024 16:36:36 -0700 Subject: [PATCH] Fix test Created using spr 1.3.4 --- bolt/test/X86/bolt-address-translation-yaml.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bolt/test/X86/bolt-address-translation-yaml.test b/bolt/test/X86/bolt-address-translation-yaml.test index be3bcb2a0c6dd1..306050a1c97e2b 100644 --- a/bolt/test/X86/bolt-address-translation-yaml.test +++ b/bolt/test/X86/bolt-address-translation-yaml.test @@ -18,7 +18,7 @@ RUN: | FileCheck --check-prefix CHECK-BOLT-YAML %s WRITE-BAT-CHECK: BOLT-INFO: Wrote 5 BAT maps WRITE-BAT-CHECK: BOLT-INFO: Wrote 4 function and 22 basic block hashes -WRITE-BAT-CHECK: BOLT-INFO: BAT section size (bytes): 380 +WRITE-BAT-CHECK: BOLT-INFO: BAT section size (bytes): 384 READ-BAT-CHECK-NOT: BOLT-ERROR: unable to save profile in YAML format for input file processed by BOLT READ-BAT-CHECK: BOLT-INFO: Parsed 5 BAT entries ___ 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 secondary entry points to BAT (PR #86218)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/86218 >From 6bc606b39044876a883aebc68fc5bbc8699094c5 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Sat, 23 Mar 2024 16:36:36 -0700 Subject: [PATCH 1/2] Fix test Created using spr 1.3.4 --- bolt/test/X86/bolt-address-translation-yaml.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bolt/test/X86/bolt-address-translation-yaml.test b/bolt/test/X86/bolt-address-translation-yaml.test index be3bcb2a0c6dd1..306050a1c97e2b 100644 --- a/bolt/test/X86/bolt-address-translation-yaml.test +++ b/bolt/test/X86/bolt-address-translation-yaml.test @@ -18,7 +18,7 @@ RUN: | FileCheck --check-prefix CHECK-BOLT-YAML %s WRITE-BAT-CHECK: BOLT-INFO: Wrote 5 BAT maps WRITE-BAT-CHECK: BOLT-INFO: Wrote 4 function and 22 basic block hashes -WRITE-BAT-CHECK: BOLT-INFO: BAT section size (bytes): 380 +WRITE-BAT-CHECK: BOLT-INFO: BAT section size (bytes): 384 READ-BAT-CHECK-NOT: BOLT-ERROR: unable to save profile in YAML format for input file processed by BOLT READ-BAT-CHECK: BOLT-INFO: Parsed 5 BAT entries >From cdf326b7bc0f1a91cc7556d4ffa105d9072c6e89 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Mon, 25 Mar 2024 13:07:43 -0700 Subject: [PATCH 2/2] Address comments, add openssl test Created using spr 1.3.4 --- bolt/lib/Profile/BoltAddressTranslation.cpp | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bolt/lib/Profile/BoltAddressTranslation.cpp b/bolt/lib/Profile/BoltAddressTranslation.cpp index 9d4ad3bcf9b429..aa4cde27e75cdb 100644 --- a/bolt/lib/Profile/BoltAddressTranslation.cpp +++ b/bolt/lib/Profile/BoltAddressTranslation.cpp @@ -194,7 +194,7 @@ void BoltAddressTranslation::writeMaps(std::map &Maps, PrevAddress = Address; const uint32_t NumSecondaryEntryPoints = SecondaryEntryPointsMap.count(Address) -? SecondaryEntryPointsMap.at(Address).size() +? SecondaryEntryPointsMap[Address].size() : 0; if (Cold) { size_t HotIndex = @@ -263,7 +263,7 @@ void BoltAddressTranslation::writeMaps(std::map &Maps, if (!Cold && NumSecondaryEntryPoints) { LLVM_DEBUG(dbgs() << "Secondary entry points: "); // Secondary entry point offsets, delta-encoded - for (uint32_t Offset : SecondaryEntryPointsMap.at(Address)) { + for (uint32_t Offset : SecondaryEntryPointsMap[Address]) { encodeULEB128(Offset - PrevOffset, OS); LLVM_DEBUG(dbgs() << formatv("{0:x} ", Offset)); PrevOffset = Offset; @@ -443,6 +443,13 @@ void BoltAddressTranslation::dump(raw_ostream &OS) { OS << formatv(" hash: {0:x}", BBHashMap.getBBHash(Val)); OS << "\n"; } +if (SecondaryEntryPointsMap.count(Address)) { + const std::vector &SecondaryEntryPoints = + SecondaryEntryPointsMap[Address]; + OS << SecondaryEntryPoints.size() << " secondary entry points:\n"; + for (uint32_t EntryPointOffset : SecondaryEntryPoints) +OS << formatv("{0:x}\n", EntryPointOffset); +} OS << "\n"; } const size_t NumColdParts = ColdPartSource.size(); ___ 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 secondary entry points to BAT (PR #86218)
https://github.com/aaupov edited https://github.com/llvm/llvm-project/pull/86218 ___ 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 secondary entry points to BAT (PR #86218)
@@ -244,6 +259,17 @@ void BoltAddressTranslation::writeMaps(std::map &Maps, InOffset >> 1, BBHash, BBIndex)); } } +uint32_t PrevOffset = 0; +if (!Cold && NumSecondaryEntryPoints) { + LLVM_DEBUG(dbgs() << "Secondary entry points: "); + // Secondary entry point offsets, delta-encoded + for (uint32_t Offset : SecondaryEntryPointsMap.at(Address)) { aaupov wrote: Thanks. Fixed in update. https://github.com/llvm/llvm-project/pull/86218 ___ 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 CallSiteInfo entries in YAMLBAT (PR #76896)
https://github.com/aaupov edited https://github.com/llvm/llvm-project/pull/76896 ___ 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 CallSiteInfo entries in YAMLBAT (PR #76896)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/76896 >From 3362e9990ee0334ab7073943b4b682764f52bc8f Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Thu, 4 Jan 2024 10:40:04 -0800 Subject: [PATCH] Assert that a function exists Created using spr 1.3.4 --- bolt/lib/Profile/BoltAddressTranslation.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bolt/lib/Profile/BoltAddressTranslation.cpp b/bolt/lib/Profile/BoltAddressTranslation.cpp index dbc9e1702a3016..62f8b777ee91b4 100644 --- a/bolt/lib/Profile/BoltAddressTranslation.cpp +++ b/bolt/lib/Profile/BoltAddressTranslation.cpp @@ -521,8 +521,7 @@ std::unordered_map> BoltAddressTranslation::getBFBranches(uint64_t OutputAddress) const { std::unordered_map> Branches; auto FuncIt = Maps.find(OutputAddress); - if (FuncIt == Maps.end()) -return Branches; + assert(FuncIt != Maps.end()); std::vector InputOffsets; for (const auto &KV : FuncIt->second) InputOffsets.emplace_back(KV.second); ___ 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 CallSiteInfo entries in YAMLBAT (PR #76896)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/76896 >From 3362e9990ee0334ab7073943b4b682764f52bc8f Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Thu, 4 Jan 2024 10:40:04 -0800 Subject: [PATCH] Assert that a function exists Created using spr 1.3.4 --- bolt/lib/Profile/BoltAddressTranslation.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bolt/lib/Profile/BoltAddressTranslation.cpp b/bolt/lib/Profile/BoltAddressTranslation.cpp index dbc9e1702a3016..62f8b777ee91b4 100644 --- a/bolt/lib/Profile/BoltAddressTranslation.cpp +++ b/bolt/lib/Profile/BoltAddressTranslation.cpp @@ -521,8 +521,7 @@ std::unordered_map> BoltAddressTranslation::getBFBranches(uint64_t OutputAddress) const { std::unordered_map> Branches; auto FuncIt = Maps.find(OutputAddress); - if (FuncIt == Maps.end()) -return Branches; + assert(FuncIt != Maps.end()); std::vector InputOffsets; for (const auto &KV : FuncIt->second) InputOffsets.emplace_back(KV.second); ___ 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] Set EntryDiscriminator in YAML profile for indirect calls (PR #82128)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/82128 ___ 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] Set EntryDiscriminator in YAML profile for indirect calls (PR #82128)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/82128 ___ 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] Set EntryDiscriminator in YAML profile for indirect calls (PR #82128)
https://github.com/aaupov edited https://github.com/llvm/llvm-project/pull/82128 ___ 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] Set EntryDiscriminator in YAML profile for indirect calls (PR #82128)
https://github.com/aaupov edited https://github.com/llvm/llvm-project/pull/82128 ___ 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] Set EntryDiscriminator in YAML profile for indirect calls (PR #82128)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/82128 >From f46d68517b6d0804f56a087c86c20c9bc3a08a0f Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Tue, 26 Mar 2024 14:23:09 -0700 Subject: [PATCH] Update test Created using spr 1.3.4 --- bolt/test/X86/yaml-indirect-call-discriminator.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bolt/test/X86/yaml-indirect-call-discriminator.s b/bolt/test/X86/yaml-indirect-call-discriminator.s index 172eba6dc31c07..c7678b3811834d 100644 --- a/bolt/test/X86/yaml-indirect-call-discriminator.s +++ b/bolt/test/X86/yaml-indirect-call-discriminator.s @@ -44,7 +44,7 @@ main: testq %rax, %rax jne Lindcall Lcall: - callsecondary_entry + callfunc # FDATA: 1 main #Lcall# 1 func 0 1 1 Lindcall: callq *%rax ___ 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] Set EntryDiscriminator in YAML profile for indirect calls (PR #82128)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/82128 >From f46d68517b6d0804f56a087c86c20c9bc3a08a0f Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Tue, 26 Mar 2024 14:23:09 -0700 Subject: [PATCH 1/2] Update test Created using spr 1.3.4 --- bolt/test/X86/yaml-indirect-call-discriminator.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bolt/test/X86/yaml-indirect-call-discriminator.s b/bolt/test/X86/yaml-indirect-call-discriminator.s index 172eba6dc31c07..c7678b3811834d 100644 --- a/bolt/test/X86/yaml-indirect-call-discriminator.s +++ b/bolt/test/X86/yaml-indirect-call-discriminator.s @@ -44,7 +44,7 @@ main: testq %rax, %rax jne Lindcall Lcall: - callsecondary_entry + callfunc # FDATA: 1 main #Lcall# 1 func 0 1 1 Lindcall: callq *%rax >From 70c242d63b6aa862eba2bb5b03ec1eb6602e0f31 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Tue, 26 Mar 2024 18:30:40 -0700 Subject: [PATCH 2/2] Align secondary entry enumeration in getSymbolForEntryID with getEntryIDForSymbol Created using spr 1.3.4 --- bolt/lib/Core/BinaryFunction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bolt/lib/Core/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp index 32bf822f077ade..c9e037c225dd41 100644 --- a/bolt/lib/Core/BinaryFunction.cpp +++ b/bolt/lib/Core/BinaryFunction.cpp @@ -3547,7 +3547,7 @@ MCSymbol *BinaryFunction::getSymbolForEntryID(uint64_t EntryID) { if (!isMultiEntry()) return nullptr; - uint64_t NumEntries = 0; + uint64_t NumEntries = 1; if (hasCFG()) { for (BinaryBasicBlock *BB : BasicBlocks) { MCSymbol *EntrySymbol = getSecondaryEntryPointSymbol(*BB); ___ 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] Set EntryDiscriminator in YAML profile for indirect calls (PR #82128)
aaupov wrote: > > Also address the issue with enumeration of secondary entry points: > > make them start with 1 instead of 0 (reserved for primary entry point). > > ^ do you want to split this in a separate commit? Makes sense. Will do. https://github.com/llvm/llvm-project/pull/82128 ___ 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] Set EntryDiscriminator in YAML profile for indirect calls (PR #82128)
aaupov wrote: Split out into https://github.com/llvm/llvm-project/pull/86848 (WIP) https://github.com/llvm/llvm-project/pull/82128 ___ 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] Set EntryDiscriminator in YAML profile for indirect calls (PR #82128)
https://github.com/aaupov edited https://github.com/llvm/llvm-project/pull/82128 ___ 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] Set EntryDiscriminator in YAML profile for indirect calls (PR #82128)
https://github.com/aaupov edited https://github.com/llvm/llvm-project/pull/82128 ___ 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] Set EntryDiscriminator in YAML profile for indirect calls (PR #82128)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/82128 >From f46d68517b6d0804f56a087c86c20c9bc3a08a0f Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Tue, 26 Mar 2024 14:23:09 -0700 Subject: [PATCH 1/2] Update test Created using spr 1.3.4 --- bolt/test/X86/yaml-indirect-call-discriminator.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bolt/test/X86/yaml-indirect-call-discriminator.s b/bolt/test/X86/yaml-indirect-call-discriminator.s index 172eba6dc31c07..c7678b3811834d 100644 --- a/bolt/test/X86/yaml-indirect-call-discriminator.s +++ b/bolt/test/X86/yaml-indirect-call-discriminator.s @@ -44,7 +44,7 @@ main: testq %rax, %rax jne Lindcall Lcall: - callsecondary_entry + callfunc # FDATA: 1 main #Lcall# 1 func 0 1 1 Lindcall: callq *%rax >From 70c242d63b6aa862eba2bb5b03ec1eb6602e0f31 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Tue, 26 Mar 2024 18:30:40 -0700 Subject: [PATCH 2/2] Align secondary entry enumeration in getSymbolForEntryID with getEntryIDForSymbol Created using spr 1.3.4 --- bolt/lib/Core/BinaryFunction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bolt/lib/Core/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp index 32bf822f077ade..c9e037c225dd41 100644 --- a/bolt/lib/Core/BinaryFunction.cpp +++ b/bolt/lib/Core/BinaryFunction.cpp @@ -3547,7 +3547,7 @@ MCSymbol *BinaryFunction::getSymbolForEntryID(uint64_t EntryID) { if (!isMultiEntry()) return nullptr; - uint64_t NumEntries = 0; + uint64_t NumEntries = 1; if (hasCFG()) { for (BinaryBasicBlock *BB : BasicBlocks) { MCSymbol *EntrySymbol = getSecondaryEntryPointSymbol(*BB); ___ 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] Set EntryDiscriminator in YAML profile for indirect calls (PR #82128)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/82128 >From f46d68517b6d0804f56a087c86c20c9bc3a08a0f Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Tue, 26 Mar 2024 14:23:09 -0700 Subject: [PATCH 1/2] Update test Created using spr 1.3.4 --- bolt/test/X86/yaml-indirect-call-discriminator.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bolt/test/X86/yaml-indirect-call-discriminator.s b/bolt/test/X86/yaml-indirect-call-discriminator.s index 172eba6dc31c07..c7678b3811834d 100644 --- a/bolt/test/X86/yaml-indirect-call-discriminator.s +++ b/bolt/test/X86/yaml-indirect-call-discriminator.s @@ -44,7 +44,7 @@ main: testq %rax, %rax jne Lindcall Lcall: - callsecondary_entry + callfunc # FDATA: 1 main #Lcall# 1 func 0 1 1 Lindcall: callq *%rax >From 70c242d63b6aa862eba2bb5b03ec1eb6602e0f31 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Tue, 26 Mar 2024 18:30:40 -0700 Subject: [PATCH 2/2] Align secondary entry enumeration in getSymbolForEntryID with getEntryIDForSymbol Created using spr 1.3.4 --- bolt/lib/Core/BinaryFunction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bolt/lib/Core/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp index 32bf822f077ade..c9e037c225dd41 100644 --- a/bolt/lib/Core/BinaryFunction.cpp +++ b/bolt/lib/Core/BinaryFunction.cpp @@ -3547,7 +3547,7 @@ MCSymbol *BinaryFunction::getSymbolForEntryID(uint64_t EntryID) { if (!isMultiEntry()) return nullptr; - uint64_t NumEntries = 0; + uint64_t NumEntries = 1; if (hasCFG()) { for (BinaryBasicBlock *BB : BasicBlocks) { MCSymbol *EntrySymbol = getSecondaryEntryPointSymbol(*BB); ___ 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] Set EntryDiscriminator in YAML profile for indirect calls (PR #82128)
@@ -78,32 +97,15 @@ YAMLProfileWriter::convert(const BinaryFunction &BF, bool UseDFS) { if (!ICSP) continue; for (const IndirectCallProfile &CSP : ICSP.get()) { - StringRef TargetName = ""; - CSI.DestId = 0; // designated for unknown functions - CSI.EntryDiscriminator = 0; - if (CSP.Symbol) { -const BinaryFunction *Callee = BC.getFunctionForSymbol(CSP.Symbol); -if (Callee) { - CSI.DestId = Callee->getFunctionNumber(); - TargetName = Callee->getOneName(); -} - } + const BinaryFunction *Callee = setCSIDestination(BC, CSI, CSP.Symbol); CSI.Count = CSP.Count; CSI.Mispreds = CSP.Mispreds; - CSTargets.emplace_back(TargetName, CSI); + if (CSI.Count && Callee) aaupov wrote: Good catch. I don't intend to change the behavior here, will fix. https://github.com/llvm/llvm-project/pull/82128 ___ 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] Set EntryDiscriminator in YAML profile for indirect calls (PR #82128)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/82128 >From f46d68517b6d0804f56a087c86c20c9bc3a08a0f Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Tue, 26 Mar 2024 14:23:09 -0700 Subject: [PATCH 1/2] Update test Created using spr 1.3.4 --- bolt/test/X86/yaml-indirect-call-discriminator.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bolt/test/X86/yaml-indirect-call-discriminator.s b/bolt/test/X86/yaml-indirect-call-discriminator.s index 172eba6dc31c07..c7678b3811834d 100644 --- a/bolt/test/X86/yaml-indirect-call-discriminator.s +++ b/bolt/test/X86/yaml-indirect-call-discriminator.s @@ -44,7 +44,7 @@ main: testq %rax, %rax jne Lindcall Lcall: - callsecondary_entry + callfunc # FDATA: 1 main #Lcall# 1 func 0 1 1 Lindcall: callq *%rax >From 70c242d63b6aa862eba2bb5b03ec1eb6602e0f31 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Tue, 26 Mar 2024 18:30:40 -0700 Subject: [PATCH 2/2] Align secondary entry enumeration in getSymbolForEntryID with getEntryIDForSymbol Created using spr 1.3.4 --- bolt/lib/Core/BinaryFunction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bolt/lib/Core/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp index 32bf822f077ade..c9e037c225dd41 100644 --- a/bolt/lib/Core/BinaryFunction.cpp +++ b/bolt/lib/Core/BinaryFunction.cpp @@ -3547,7 +3547,7 @@ MCSymbol *BinaryFunction::getSymbolForEntryID(uint64_t EntryID) { if (!isMultiEntry()) return nullptr; - uint64_t NumEntries = 0; + uint64_t NumEntries = 1; if (hasCFG()) { for (BinaryBasicBlock *BB : BasicBlocks) { MCSymbol *EntrySymbol = getSecondaryEntryPointSymbol(*BB); ___ 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] Set EntryDiscriminator in YAML profile for indirect calls (PR #82128)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/82128 >From f46d68517b6d0804f56a087c86c20c9bc3a08a0f Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Tue, 26 Mar 2024 14:23:09 -0700 Subject: [PATCH 1/2] Update test Created using spr 1.3.4 --- bolt/test/X86/yaml-indirect-call-discriminator.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bolt/test/X86/yaml-indirect-call-discriminator.s b/bolt/test/X86/yaml-indirect-call-discriminator.s index 172eba6dc31c07..c7678b3811834d 100644 --- a/bolt/test/X86/yaml-indirect-call-discriminator.s +++ b/bolt/test/X86/yaml-indirect-call-discriminator.s @@ -44,7 +44,7 @@ main: testq %rax, %rax jne Lindcall Lcall: - callsecondary_entry + callfunc # FDATA: 1 main #Lcall# 1 func 0 1 1 Lindcall: callq *%rax >From 70c242d63b6aa862eba2bb5b03ec1eb6602e0f31 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Tue, 26 Mar 2024 18:30:40 -0700 Subject: [PATCH 2/2] Align secondary entry enumeration in getSymbolForEntryID with getEntryIDForSymbol Created using spr 1.3.4 --- bolt/lib/Core/BinaryFunction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bolt/lib/Core/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp index 32bf822f077ade..c9e037c225dd41 100644 --- a/bolt/lib/Core/BinaryFunction.cpp +++ b/bolt/lib/Core/BinaryFunction.cpp @@ -3547,7 +3547,7 @@ MCSymbol *BinaryFunction::getSymbolForEntryID(uint64_t EntryID) { if (!isMultiEntry()) return nullptr; - uint64_t NumEntries = 0; + uint64_t NumEntries = 1; if (hasCFG()) { for (BinaryBasicBlock *BB : BasicBlocks) { MCSymbol *EntrySymbol = getSecondaryEntryPointSymbol(*BB); ___ 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] Set EntryDiscriminator in YAML profile for indirect calls (PR #82128)
https://github.com/aaupov edited https://github.com/llvm/llvm-project/pull/82128 ___ 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] Set EntryDiscriminator in YAML profile for indirect calls (PR #82128)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/82128 >From f46d68517b6d0804f56a087c86c20c9bc3a08a0f Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Tue, 26 Mar 2024 14:23:09 -0700 Subject: [PATCH 1/2] Update test Created using spr 1.3.4 --- bolt/test/X86/yaml-indirect-call-discriminator.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bolt/test/X86/yaml-indirect-call-discriminator.s b/bolt/test/X86/yaml-indirect-call-discriminator.s index 172eba6dc31c07..c7678b3811834d 100644 --- a/bolt/test/X86/yaml-indirect-call-discriminator.s +++ b/bolt/test/X86/yaml-indirect-call-discriminator.s @@ -44,7 +44,7 @@ main: testq %rax, %rax jne Lindcall Lcall: - callsecondary_entry + callfunc # FDATA: 1 main #Lcall# 1 func 0 1 1 Lindcall: callq *%rax >From 70c242d63b6aa862eba2bb5b03ec1eb6602e0f31 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Tue, 26 Mar 2024 18:30:40 -0700 Subject: [PATCH 2/2] Align secondary entry enumeration in getSymbolForEntryID with getEntryIDForSymbol Created using spr 1.3.4 --- bolt/lib/Core/BinaryFunction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bolt/lib/Core/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp index 32bf822f077ade..c9e037c225dd41 100644 --- a/bolt/lib/Core/BinaryFunction.cpp +++ b/bolt/lib/Core/BinaryFunction.cpp @@ -3547,7 +3547,7 @@ MCSymbol *BinaryFunction::getSymbolForEntryID(uint64_t EntryID) { if (!isMultiEntry()) return nullptr; - uint64_t NumEntries = 0; + uint64_t NumEntries = 1; if (hasCFG()) { for (BinaryBasicBlock *BB : BasicBlocks) { MCSymbol *EntrySymbol = getSecondaryEntryPointSymbol(*BB); ___ 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] Set EntryDiscriminator in YAML profile for indirect calls (PR #82128)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/82128 >From f46d68517b6d0804f56a087c86c20c9bc3a08a0f Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Tue, 26 Mar 2024 14:23:09 -0700 Subject: [PATCH 1/2] Update test Created using spr 1.3.4 --- bolt/test/X86/yaml-indirect-call-discriminator.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bolt/test/X86/yaml-indirect-call-discriminator.s b/bolt/test/X86/yaml-indirect-call-discriminator.s index 172eba6dc31c07..c7678b3811834d 100644 --- a/bolt/test/X86/yaml-indirect-call-discriminator.s +++ b/bolt/test/X86/yaml-indirect-call-discriminator.s @@ -44,7 +44,7 @@ main: testq %rax, %rax jne Lindcall Lcall: - callsecondary_entry + callfunc # FDATA: 1 main #Lcall# 1 func 0 1 1 Lindcall: callq *%rax >From 70c242d63b6aa862eba2bb5b03ec1eb6602e0f31 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Tue, 26 Mar 2024 18:30:40 -0700 Subject: [PATCH 2/2] Align secondary entry enumeration in getSymbolForEntryID with getEntryIDForSymbol Created using spr 1.3.4 --- bolt/lib/Core/BinaryFunction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bolt/lib/Core/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp index 32bf822f077ade..c9e037c225dd41 100644 --- a/bolt/lib/Core/BinaryFunction.cpp +++ b/bolt/lib/Core/BinaryFunction.cpp @@ -3547,7 +3547,7 @@ MCSymbol *BinaryFunction::getSymbolForEntryID(uint64_t EntryID) { if (!isMultiEntry()) return nullptr; - uint64_t NumEntries = 0; + uint64_t NumEntries = 1; if (hasCFG()) { for (BinaryBasicBlock *BB : BasicBlocks) { MCSymbol *EntrySymbol = getSecondaryEntryPointSymbol(*BB); ___ 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 BAT callbacks in YAMLProfileWriter::convert (PR #86219)
https://github.com/aaupov edited 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] Use BAT callbacks in YAMLProfileWriter::convert (PR #86219)
https://github.com/aaupov updated 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] Use BAT callbacks in YAMLProfileWriter::convert (PR #86219)
https://github.com/aaupov updated 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] Use BAT callbacks in YAMLProfileWriter::convert (PR #86219)
https://github.com/aaupov edited 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] [llvm] [BOLT] Use BAT callbacks in YAMLProfileWriter::convert (PR #86219)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/86219 >From 685d3f5fa6ae75d6c3e22873a52ea8347e170c1e Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Thu, 28 Mar 2024 10:16:15 -0700 Subject: [PATCH] Get rid of std::map::at Created using spr 1.3.4 --- bolt/lib/Profile/BoltAddressTranslation.cpp | 5 - bolt/lib/Profile/YAMLProfileWriter.cpp | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/bolt/lib/Profile/BoltAddressTranslation.cpp b/bolt/lib/Profile/BoltAddressTranslation.cpp index 6d3f83efbe5f5a..7c54ba1971cbac 100644 --- a/bolt/lib/Profile/BoltAddressTranslation.cpp +++ b/bolt/lib/Profile/BoltAddressTranslation.cpp @@ -600,7 +600,10 @@ BoltAddressTranslation::getBFBranches(uint64_t OutputAddress) const { unsigned BoltAddressTranslation::getSecondaryEntryPointId(uint64_t Address, uint32_t Offset) const { - const std::vector &Offsets = SecondaryEntryPointsMap.at(Address); + auto FunctionIt = SecondaryEntryPointsMap.find(Address); + if (FunctionIt == SecondaryEntryPointsMap.end()) +return UINT_MAX; + const std::vector &Offsets = FunctionIt->second; auto OffsetIt = std::find(Offsets.begin(), Offsets.end(), Offset); if (OffsetIt == Offsets.end()) return UINT_MAX; diff --git a/bolt/lib/Profile/YAMLProfileWriter.cpp b/bolt/lib/Profile/YAMLProfileWriter.cpp index 78fb1e8539d477..bacee136de3f87 100644 --- a/bolt/lib/Profile/YAMLProfileWriter.cpp +++ b/bolt/lib/Profile/YAMLProfileWriter.cpp @@ -48,7 +48,8 @@ setCSIDestination(const BinaryContext &BC, yaml::bolt::CallSiteInfo &CSI, if (SymbolValue.getError()) return Callee; if (uint32_t Offset = SymbolValue.get() - Callee->getAddress()) - EntryID = (*GetBATSecondaryEntryPointId)(Callee->getAddress(), Offset); + EntryID = + (*GetBATSecondaryEntryPointId)(Callee->getAddress(), Offset) + 1; } else { BC.getFunctionForSymbol(Symbol, &EntryID); } ___ 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 callbacks in YAMLProfileWriter::convert (PR #86219)
https://github.com/aaupov converted_to_draft 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] [llvm] [BOLT] Use BAT callbacks in YAMLProfileWriter::convert (PR #86219)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/86219 >From 685d3f5fa6ae75d6c3e22873a52ea8347e170c1e Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Thu, 28 Mar 2024 10:16:15 -0700 Subject: [PATCH 1/2] Get rid of std::map::at Created using spr 1.3.4 --- bolt/lib/Profile/BoltAddressTranslation.cpp | 5 - bolt/lib/Profile/YAMLProfileWriter.cpp | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/bolt/lib/Profile/BoltAddressTranslation.cpp b/bolt/lib/Profile/BoltAddressTranslation.cpp index 6d3f83efbe5f5a..7c54ba1971cbac 100644 --- a/bolt/lib/Profile/BoltAddressTranslation.cpp +++ b/bolt/lib/Profile/BoltAddressTranslation.cpp @@ -600,7 +600,10 @@ BoltAddressTranslation::getBFBranches(uint64_t OutputAddress) const { unsigned BoltAddressTranslation::getSecondaryEntryPointId(uint64_t Address, uint32_t Offset) const { - const std::vector &Offsets = SecondaryEntryPointsMap.at(Address); + auto FunctionIt = SecondaryEntryPointsMap.find(Address); + if (FunctionIt == SecondaryEntryPointsMap.end()) +return UINT_MAX; + const std::vector &Offsets = FunctionIt->second; auto OffsetIt = std::find(Offsets.begin(), Offsets.end(), Offset); if (OffsetIt == Offsets.end()) return UINT_MAX; diff --git a/bolt/lib/Profile/YAMLProfileWriter.cpp b/bolt/lib/Profile/YAMLProfileWriter.cpp index 78fb1e8539d477..bacee136de3f87 100644 --- a/bolt/lib/Profile/YAMLProfileWriter.cpp +++ b/bolt/lib/Profile/YAMLProfileWriter.cpp @@ -48,7 +48,8 @@ setCSIDestination(const BinaryContext &BC, yaml::bolt::CallSiteInfo &CSI, if (SymbolValue.getError()) return Callee; if (uint32_t Offset = SymbolValue.get() - Callee->getAddress()) - EntryID = (*GetBATSecondaryEntryPointId)(Callee->getAddress(), Offset); + EntryID = + (*GetBATSecondaryEntryPointId)(Callee->getAddress(), Offset) + 1; } else { BC.getFunctionForSymbol(Symbol, &EntryID); } >From 03520283ff38a47bc44cfa395534837d8da66934 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Thu, 28 Mar 2024 22:37:24 -0700 Subject: [PATCH 2/2] Fixed setting of BAT secondary entry point, updated test Created using spr 1.3.4 --- bolt/include/bolt/Profile/YAMLProfileWriter.h | 11 +-- bolt/lib/Profile/DataAggregator.cpp | 11 +-- bolt/lib/Profile/YAMLProfileWriter.cpp| 71 --- .../X86/yaml-secondary-entry-discriminator.s | 52 +- 4 files changed, 97 insertions(+), 48 deletions(-) diff --git a/bolt/include/bolt/Profile/YAMLProfileWriter.h b/bolt/include/bolt/Profile/YAMLProfileWriter.h index 7db581652a5b73..0db2e3fd90f9f1 100644 --- a/bolt/include/bolt/Profile/YAMLProfileWriter.h +++ b/bolt/include/bolt/Profile/YAMLProfileWriter.h @@ -15,6 +15,7 @@ namespace llvm { namespace bolt { +class BoltAddressTranslation; class RewriteInstance; class YAMLProfileWriter { @@ -31,17 +32,9 @@ class YAMLProfileWriter { /// Save execution profile for that instance. std::error_code writeProfile(const RewriteInstance &RI); - /// Callback to determine if a function is covered by BAT. - using IsBATCallbackTy = std::optional>; - /// Callback to get secondary entry point id for a given function and offset. - using GetBATSecondaryEntryPointIdCallbackTy = - std::optional>; - static yaml::bolt::BinaryFunctionProfile convert(const BinaryFunction &BF, bool UseDFS, - IsBATCallbackTy IsBATFunction = std::nullopt, - GetBATSecondaryEntryPointIdCallbackTy GetBATSecondaryEntryPointId = - std::nullopt); + const BoltAddressTranslation *BAT = nullptr); }; } // namespace bolt diff --git a/bolt/lib/Profile/DataAggregator.cpp b/bolt/lib/Profile/DataAggregator.cpp index 5b5ce5532ffdb9..71824e2cc0e97a 100644 --- a/bolt/lib/Profile/DataAggregator.cpp +++ b/bolt/lib/Profile/DataAggregator.cpp @@ -2324,13 +2324,6 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC, BP.Header.Flags = opts::BasicAggregation ? BinaryFunction::PF_SAMPLE : BinaryFunction::PF_LBR; - auto IsBATFunction = [&](uint64_t Address) { -return BAT->isBATFunction(Address); - }; - auto GetSecondaryEntryPointId = [&](uint64_t Address, uint32_t Offset) { -return BAT->getSecondaryEntryPointId(Address, Offset); - }; - if (!opts::BasicAggregation) { // Convert profile for functions not covered by BAT for (auto &BFI : BC.getBinaryFunctions()) { @@ -2339,8 +2332,8 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC, continue; if (BAT->isBATFunction(Function.getAddress())) continue; - BP.Functions.emplace_back(YAMLProfileWriter::convert( - Function, /*UseDFS=*/false, IsBATFunction, GetSecondaryEntryPointId)); + BP.Functions.emplace_back( + YAMLProfileWriter::convert(Function, /*UseDFS=*/false, BAT)); } for (const auto &KV : Names
[llvm-branch-commits] [llvm] [BOLT] Use BAT interfaces in YAMLProfileWriter::convert (PR #86219)
https://github.com/aaupov edited 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] [llvm] [BOLT] Use BAT interfaces in YAMLProfileWriter::convert (PR #86219)
https://github.com/aaupov ready_for_review 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][BAT] Support multi-way split functions (PR #87123)
https://github.com/aaupov created https://github.com/llvm/llvm-project/pull/87123 BAT writeMaps encoded the assumption that functions are only split into two fragments (hot and cold). However, BOLT supports splitting into arbitrary number of fragments. Relax that assumption and look up primary (hot) fragment explicitly. Test Plan: Updated bolt/test/X86/yaml-secondary-entry-discriminator.s ___ 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] Support multi-way split functions (PR #87123)
https://github.com/aaupov edited https://github.com/llvm/llvm-project/pull/87123 ___ 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)
aaupov wrote: > I don't think Test plan in summary is necessary. `spr` tool complains if there's no test plan, and I tend to agree with it. But I'm neutral about removing that. 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] [llvm] [BOLT][BAT] Support multi-way split functions (PR #87123)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/87123 >From d575235e6d61ea73757ec313a26b8b2aedc2c13d Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Fri, 29 Mar 2024 20:14:11 -0700 Subject: [PATCH] Address comment Created using spr 1.3.4 --- bolt/lib/Profile/BoltAddressTranslation.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/bolt/lib/Profile/BoltAddressTranslation.cpp b/bolt/lib/Profile/BoltAddressTranslation.cpp index 2c00bf6291eb9c..279490170ed446 100644 --- a/bolt/lib/Profile/BoltAddressTranslation.cpp +++ b/bolt/lib/Profile/BoltAddressTranslation.cpp @@ -197,7 +197,6 @@ void BoltAddressTranslation::writeMaps(std::map &Maps, ? SecondaryEntryPointsMap[Address].size() : 0; if (Cold) { - // `Maps` is keyed by output addresses. auto HotEntryIt = Maps.find(ColdPartSource[Address]); assert(HotEntryIt != Maps.end()); size_t HotIndex = std::distance(Maps.begin(), HotEntryIt); ___ 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][BAT] Support multi-way split functions (PR #87123)
@@ -197,8 +197,10 @@ void BoltAddressTranslation::writeMaps(std::map &Maps, ? SecondaryEntryPointsMap[Address].size() : 0; if (Cold) { - size_t HotIndex = - std::distance(ColdPartSource.begin(), ColdPartSource.find(Address)); + // `Maps` is keyed by output addresses. aaupov wrote: I'm fine with removing that comment. It's explained in multiple places including BAT documentation. https://github.com/llvm/llvm-project/pull/87123 ___ 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 binary introspection/JIT manager (PR #81346)
aaupov wrote: I split out `createBinaryContext` change into https://github.com/llvm/llvm-project/pull/87172 to facilitate this review. https://github.com/llvm/llvm-project/pull/81346 ___ 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 binary introspection/JIT manager (PR #81346)
@@ -0,0 +1,367 @@ +//===- bolt/Rewrite/JITRewriteInstance.cpp - JIT rewriter -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "bolt/Rewrite/JITRewriteInstance.h" +#include "bolt/Core/BinaryContext.h" +#include "bolt/Core/BinaryEmitter.h" +#include "bolt/Core/BinaryFunction.h" +#include "bolt/Core/JumpTable.h" +#include "bolt/Core/MCPlusBuilder.h" +#include "bolt/Profile/DataAggregator.h" +#include "bolt/Rewrite/BinaryPassManager.h" +#include "bolt/Rewrite/RewriteInstance.h" +#include "bolt/Utils/Utils.h" +#include "llvm/MC/MCAsmLayout.h" +#include "llvm/MC/MCObjectStreamer.h" +#include "llvm/Object/SymbolSize.h" +#include "llvm/Support/Errc.h" +#include "llvm/Support/FileSystem.h" +#include + +namespace opts { + +using namespace llvm; +extern cl::opt AlignText; +extern cl::opt PrintSections; +extern cl::opt PrintDisasm; +extern cl::opt PrintCFG; +extern cl::opt Verbosity; +} // namespace opts + +namespace llvm { +namespace bolt { + +#define DEBUG_TYPE "bolt" + +Expected> +JITRewriteInstance::createJITRewriteInstance(JournalingStreams Logger, + bool IsPIC) { + Error Err = Error::success(); + std::unique_ptr JITRI( + new JITRewriteInstance(Logger, IsPIC, Err)); + if (Err) +return std::move(Err); + return std::move(JITRI); +} + +JITRewriteInstance::JITRewriteInstance(JournalingStreams Logger, bool IsPIC, + Error &Err) +: StrPool(StrAllocator) { + ErrorAsOutParameter EAO(&Err); + Triple TheTriple(sys::getDefaultTargetTriple().c_str()); + + auto BCOrErr = BinaryContext::createBinaryContext( + TheTriple, StringRef("JIT input file"), nullptr, IsPIC, nullptr, Logger); + if (Error E = BCOrErr.takeError()) { +Err = std::move(E); +return; + } + BC = std::move(BCOrErr.get()); + BC->initializeTarget(std::unique_ptr( + createMCPlusBuilder(BC->TheTriple->getArch(), BC->MIA.get(), + BC->MII.get(), BC->MRI.get(), BC->STI.get(; + BC->FirstAllocAddress = 0; + BC->LayoutStartAddress = 0x; +} + +JITRewriteInstance::~JITRewriteInstance() {} + +void JITRewriteInstance::adjustCommandLineOptions() { + if (!opts::AlignText.getNumOccurrences()) +opts::AlignText = BC->PageAlign; +} + +Error JITRewriteInstance::preprocessProfileData() { + if (!ProfileReader) +return Error::success(); + if (Error E = ProfileReader->preprocessProfile(*BC.get())) +return Error(std::move(E)); + return Error::success(); +} + +Error JITRewriteInstance::processProfileDataPreCFG() { + if (!ProfileReader) +return Error::success(); + if (Error E = ProfileReader->readProfilePreCFG(*BC.get())) +return Error(std::move(E)); + return Error::success(); +} + +Error JITRewriteInstance::processProfileData() { + if (!ProfileReader) +return Error::success(); + if (Error E = ProfileReader->readProfile(*BC.get())) +return Error(std::move(E)); + return Error::success(); +} + +Error JITRewriteInstance::disassembleFunctions() { aaupov wrote: I believe that this and other functions are common across *RewriteInstance classes. Is it worth defining a BaseRewriteInstance class and providing them there? https://github.com/llvm/llvm-project/pull/81346 ___ 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 binary introspection/JIT manager (PR #81346)
https://github.com/aaupov edited https://github.com/llvm/llvm-project/pull/81346 ___ 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)
@@ -27,25 +28,55 @@ namespace bolt { /// Set CallSiteInfo destination fields from \p Symbol and return a target /// BinaryFunction for that symbol. -static const BinaryFunction *setCSIDestination(const BinaryContext &BC, - yaml::bolt::CallSiteInfo &CSI, - const MCSymbol *Symbol) { +static const BinaryFunction * +setCSIDestination(const BinaryContext &BC, yaml::bolt::CallSiteInfo &CSI, + const MCSymbol *Symbol, const BoltAddressTranslation *BAT) { CSI.DestId = 0; // designated for unknown functions CSI.EntryDiscriminator = 0; + auto setBATSecondaryEntry = [&](const BinaryFunction *const Callee) { +// The symbol could be a secondary entry in a cold fragment. +ErrorOr SymbolValue = BC.getSymbolValue(*Symbol); +if (SymbolValue.getError()) aaupov wrote: We shouldn't. Let me just use `cantFail` wrapper here. 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] [llvm] [BOLT] Use BAT interfaces in YAMLProfileWriter::convert (PR #86219)
@@ -27,25 +28,55 @@ namespace bolt { /// Set CallSiteInfo destination fields from \p Symbol and return a target /// BinaryFunction for that symbol. -static const BinaryFunction *setCSIDestination(const BinaryContext &BC, - yaml::bolt::CallSiteInfo &CSI, - const MCSymbol *Symbol) { +static const BinaryFunction * +setCSIDestination(const BinaryContext &BC, yaml::bolt::CallSiteInfo &CSI, + const MCSymbol *Symbol, const BoltAddressTranslation *BAT) { CSI.DestId = 0; // designated for unknown functions CSI.EntryDiscriminator = 0; + auto setBATSecondaryEntry = [&](const BinaryFunction *const Callee) { +// The symbol could be a secondary entry in a cold fragment. +ErrorOr SymbolValue = BC.getSymbolValue(*Symbol); +if (SymbolValue.getError()) + return; + +// Containing function, not necessarily the same as symbol value. +const uint64_t CalleeAddress = Callee->getAddress(); +const uint32_t OutputOffset = SymbolValue.get() - CalleeAddress; + +const uint64_t ParentAddress = BAT->fetchParentAddress(CalleeAddress); +const uint64_t HotAddress = ParentAddress ? ParentAddress : CalleeAddress; + +if (const BinaryFunction *ParentBF = +BC.getBinaryFunctionAtAddress(HotAddress)) + CSI.DestId = ParentBF->getFunctionNumber(); + +const uint32_t InputOffset = +BAT->translate(CalleeAddress, OutputOffset, /*IsBranchSrc*/ false); + +if (!InputOffset) + return; + +CSI.EntryDiscriminator = +BAT->getSecondaryEntryPointId(HotAddress, InputOffset) + 1; + }; + if (Symbol) { uint64_t EntryID = 0; if (const BinaryFunction *const Callee = BC.getFunctionForSymbol(Symbol, &EntryID)) { CSI.DestId = Callee->getFunctionNumber(); CSI.EntryDiscriminator = EntryID; + if (BAT && BAT->isBATFunction(Callee->getAddress())) +setBATSecondaryEntry(Callee); aaupov wrote: I'd rather have `getFunctionForSymbol` stay the same, as we deal with BAT exclusively in profile-related code. Moving BAT to BC from RI would be an ergonomic change regardless. 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] [llvm] [BOLT] Use BAT interfaces in YAMLProfileWriter::convert (PR #86219)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/86219 >From 685d3f5fa6ae75d6c3e22873a52ea8347e170c1e Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Thu, 28 Mar 2024 10:16:15 -0700 Subject: [PATCH 1/2] Get rid of std::map::at Created using spr 1.3.4 --- bolt/lib/Profile/BoltAddressTranslation.cpp | 5 - bolt/lib/Profile/YAMLProfileWriter.cpp | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/bolt/lib/Profile/BoltAddressTranslation.cpp b/bolt/lib/Profile/BoltAddressTranslation.cpp index 6d3f83efbe5f5a..7c54ba1971cbac 100644 --- a/bolt/lib/Profile/BoltAddressTranslation.cpp +++ b/bolt/lib/Profile/BoltAddressTranslation.cpp @@ -600,7 +600,10 @@ BoltAddressTranslation::getBFBranches(uint64_t OutputAddress) const { unsigned BoltAddressTranslation::getSecondaryEntryPointId(uint64_t Address, uint32_t Offset) const { - const std::vector &Offsets = SecondaryEntryPointsMap.at(Address); + auto FunctionIt = SecondaryEntryPointsMap.find(Address); + if (FunctionIt == SecondaryEntryPointsMap.end()) +return UINT_MAX; + const std::vector &Offsets = FunctionIt->second; auto OffsetIt = std::find(Offsets.begin(), Offsets.end(), Offset); if (OffsetIt == Offsets.end()) return UINT_MAX; diff --git a/bolt/lib/Profile/YAMLProfileWriter.cpp b/bolt/lib/Profile/YAMLProfileWriter.cpp index 78fb1e8539d477..bacee136de3f87 100644 --- a/bolt/lib/Profile/YAMLProfileWriter.cpp +++ b/bolt/lib/Profile/YAMLProfileWriter.cpp @@ -48,7 +48,8 @@ setCSIDestination(const BinaryContext &BC, yaml::bolt::CallSiteInfo &CSI, if (SymbolValue.getError()) return Callee; if (uint32_t Offset = SymbolValue.get() - Callee->getAddress()) - EntryID = (*GetBATSecondaryEntryPointId)(Callee->getAddress(), Offset); + EntryID = + (*GetBATSecondaryEntryPointId)(Callee->getAddress(), Offset) + 1; } else { BC.getFunctionForSymbol(Symbol, &EntryID); } >From 03520283ff38a47bc44cfa395534837d8da66934 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Thu, 28 Mar 2024 22:37:24 -0700 Subject: [PATCH 2/2] Fixed setting of BAT secondary entry point, updated test Created using spr 1.3.4 --- bolt/include/bolt/Profile/YAMLProfileWriter.h | 11 +-- bolt/lib/Profile/DataAggregator.cpp | 11 +-- bolt/lib/Profile/YAMLProfileWriter.cpp| 71 --- .../X86/yaml-secondary-entry-discriminator.s | 52 +- 4 files changed, 97 insertions(+), 48 deletions(-) diff --git a/bolt/include/bolt/Profile/YAMLProfileWriter.h b/bolt/include/bolt/Profile/YAMLProfileWriter.h index 7db581652a5b73..0db2e3fd90f9f1 100644 --- a/bolt/include/bolt/Profile/YAMLProfileWriter.h +++ b/bolt/include/bolt/Profile/YAMLProfileWriter.h @@ -15,6 +15,7 @@ namespace llvm { namespace bolt { +class BoltAddressTranslation; class RewriteInstance; class YAMLProfileWriter { @@ -31,17 +32,9 @@ class YAMLProfileWriter { /// Save execution profile for that instance. std::error_code writeProfile(const RewriteInstance &RI); - /// Callback to determine if a function is covered by BAT. - using IsBATCallbackTy = std::optional>; - /// Callback to get secondary entry point id for a given function and offset. - using GetBATSecondaryEntryPointIdCallbackTy = - std::optional>; - static yaml::bolt::BinaryFunctionProfile convert(const BinaryFunction &BF, bool UseDFS, - IsBATCallbackTy IsBATFunction = std::nullopt, - GetBATSecondaryEntryPointIdCallbackTy GetBATSecondaryEntryPointId = - std::nullopt); + const BoltAddressTranslation *BAT = nullptr); }; } // namespace bolt diff --git a/bolt/lib/Profile/DataAggregator.cpp b/bolt/lib/Profile/DataAggregator.cpp index 5b5ce5532ffdb9..71824e2cc0e97a 100644 --- a/bolt/lib/Profile/DataAggregator.cpp +++ b/bolt/lib/Profile/DataAggregator.cpp @@ -2324,13 +2324,6 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC, BP.Header.Flags = opts::BasicAggregation ? BinaryFunction::PF_SAMPLE : BinaryFunction::PF_LBR; - auto IsBATFunction = [&](uint64_t Address) { -return BAT->isBATFunction(Address); - }; - auto GetSecondaryEntryPointId = [&](uint64_t Address, uint32_t Offset) { -return BAT->getSecondaryEntryPointId(Address, Offset); - }; - if (!opts::BasicAggregation) { // Convert profile for functions not covered by BAT for (auto &BFI : BC.getBinaryFunctions()) { @@ -2339,8 +2332,8 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC, continue; if (BAT->isBATFunction(Function.getAddress())) continue; - BP.Functions.emplace_back(YAMLProfileWriter::convert( - Function, /*UseDFS=*/false, IsBATFunction, GetSecondaryEntryPointId)); + BP.Functions.emplace_back( + YAMLProfileWriter::convert(Function, /*UseDFS=*/false, BAT)); } for (const auto &KV : Names
[llvm-branch-commits] [llvm] [BOLT] Use BAT interfaces in YAMLProfileWriter::convert (PR #86219)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/86219 >From 685d3f5fa6ae75d6c3e22873a52ea8347e170c1e Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Thu, 28 Mar 2024 10:16:15 -0700 Subject: [PATCH 1/2] Get rid of std::map::at Created using spr 1.3.4 --- bolt/lib/Profile/BoltAddressTranslation.cpp | 5 - bolt/lib/Profile/YAMLProfileWriter.cpp | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/bolt/lib/Profile/BoltAddressTranslation.cpp b/bolt/lib/Profile/BoltAddressTranslation.cpp index 6d3f83efbe5f5a..7c54ba1971cbac 100644 --- a/bolt/lib/Profile/BoltAddressTranslation.cpp +++ b/bolt/lib/Profile/BoltAddressTranslation.cpp @@ -600,7 +600,10 @@ BoltAddressTranslation::getBFBranches(uint64_t OutputAddress) const { unsigned BoltAddressTranslation::getSecondaryEntryPointId(uint64_t Address, uint32_t Offset) const { - const std::vector &Offsets = SecondaryEntryPointsMap.at(Address); + auto FunctionIt = SecondaryEntryPointsMap.find(Address); + if (FunctionIt == SecondaryEntryPointsMap.end()) +return UINT_MAX; + const std::vector &Offsets = FunctionIt->second; auto OffsetIt = std::find(Offsets.begin(), Offsets.end(), Offset); if (OffsetIt == Offsets.end()) return UINT_MAX; diff --git a/bolt/lib/Profile/YAMLProfileWriter.cpp b/bolt/lib/Profile/YAMLProfileWriter.cpp index 78fb1e8539d477..bacee136de3f87 100644 --- a/bolt/lib/Profile/YAMLProfileWriter.cpp +++ b/bolt/lib/Profile/YAMLProfileWriter.cpp @@ -48,7 +48,8 @@ setCSIDestination(const BinaryContext &BC, yaml::bolt::CallSiteInfo &CSI, if (SymbolValue.getError()) return Callee; if (uint32_t Offset = SymbolValue.get() - Callee->getAddress()) - EntryID = (*GetBATSecondaryEntryPointId)(Callee->getAddress(), Offset); + EntryID = + (*GetBATSecondaryEntryPointId)(Callee->getAddress(), Offset) + 1; } else { BC.getFunctionForSymbol(Symbol, &EntryID); } >From 03520283ff38a47bc44cfa395534837d8da66934 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Thu, 28 Mar 2024 22:37:24 -0700 Subject: [PATCH 2/2] Fixed setting of BAT secondary entry point, updated test Created using spr 1.3.4 --- bolt/include/bolt/Profile/YAMLProfileWriter.h | 11 +-- bolt/lib/Profile/DataAggregator.cpp | 11 +-- bolt/lib/Profile/YAMLProfileWriter.cpp| 71 --- .../X86/yaml-secondary-entry-discriminator.s | 52 +- 4 files changed, 97 insertions(+), 48 deletions(-) diff --git a/bolt/include/bolt/Profile/YAMLProfileWriter.h b/bolt/include/bolt/Profile/YAMLProfileWriter.h index 7db581652a5b73..0db2e3fd90f9f1 100644 --- a/bolt/include/bolt/Profile/YAMLProfileWriter.h +++ b/bolt/include/bolt/Profile/YAMLProfileWriter.h @@ -15,6 +15,7 @@ namespace llvm { namespace bolt { +class BoltAddressTranslation; class RewriteInstance; class YAMLProfileWriter { @@ -31,17 +32,9 @@ class YAMLProfileWriter { /// Save execution profile for that instance. std::error_code writeProfile(const RewriteInstance &RI); - /// Callback to determine if a function is covered by BAT. - using IsBATCallbackTy = std::optional>; - /// Callback to get secondary entry point id for a given function and offset. - using GetBATSecondaryEntryPointIdCallbackTy = - std::optional>; - static yaml::bolt::BinaryFunctionProfile convert(const BinaryFunction &BF, bool UseDFS, - IsBATCallbackTy IsBATFunction = std::nullopt, - GetBATSecondaryEntryPointIdCallbackTy GetBATSecondaryEntryPointId = - std::nullopt); + const BoltAddressTranslation *BAT = nullptr); }; } // namespace bolt diff --git a/bolt/lib/Profile/DataAggregator.cpp b/bolt/lib/Profile/DataAggregator.cpp index 5b5ce5532ffdb9..71824e2cc0e97a 100644 --- a/bolt/lib/Profile/DataAggregator.cpp +++ b/bolt/lib/Profile/DataAggregator.cpp @@ -2324,13 +2324,6 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC, BP.Header.Flags = opts::BasicAggregation ? BinaryFunction::PF_SAMPLE : BinaryFunction::PF_LBR; - auto IsBATFunction = [&](uint64_t Address) { -return BAT->isBATFunction(Address); - }; - auto GetSecondaryEntryPointId = [&](uint64_t Address, uint32_t Offset) { -return BAT->getSecondaryEntryPointId(Address, Offset); - }; - if (!opts::BasicAggregation) { // Convert profile for functions not covered by BAT for (auto &BFI : BC.getBinaryFunctions()) { @@ -2339,8 +2332,8 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC, continue; if (BAT->isBATFunction(Function.getAddress())) continue; - BP.Functions.emplace_back(YAMLProfileWriter::convert( - Function, /*UseDFS=*/false, IsBATFunction, GetSecondaryEntryPointId)); + BP.Functions.emplace_back( + YAMLProfileWriter::convert(Function, /*UseDFS=*/false, BAT)); } for (const auto &KV : Names
[llvm-branch-commits] [llvm] [BOLT][BAT] Support multi-way split functions (PR #87123)
@@ -197,8 +197,10 @@ void BoltAddressTranslation::writeMaps(std::map &Maps, ? SecondaryEntryPointsMap[Address].size() : 0; if (Cold) { - size_t HotIndex = - std::distance(ColdPartSource.begin(), ColdPartSource.find(Address)); + // `Maps` is keyed by output addresses. + auto HotEntryIt = Maps.find(ColdPartSource[Address]); + assert(HotEntryIt != Maps.end()); aaupov wrote: This is BAT writing code, so it's an internal invariant (should be an assertion). https://github.com/llvm/llvm-project/pull/87123 ___ 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)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/86219 >From 685d3f5fa6ae75d6c3e22873a52ea8347e170c1e Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Thu, 28 Mar 2024 10:16:15 -0700 Subject: [PATCH 1/3] Get rid of std::map::at Created using spr 1.3.4 --- bolt/lib/Profile/BoltAddressTranslation.cpp | 5 - bolt/lib/Profile/YAMLProfileWriter.cpp | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/bolt/lib/Profile/BoltAddressTranslation.cpp b/bolt/lib/Profile/BoltAddressTranslation.cpp index 6d3f83efbe5f5a..7c54ba1971cbac 100644 --- a/bolt/lib/Profile/BoltAddressTranslation.cpp +++ b/bolt/lib/Profile/BoltAddressTranslation.cpp @@ -600,7 +600,10 @@ BoltAddressTranslation::getBFBranches(uint64_t OutputAddress) const { unsigned BoltAddressTranslation::getSecondaryEntryPointId(uint64_t Address, uint32_t Offset) const { - const std::vector &Offsets = SecondaryEntryPointsMap.at(Address); + auto FunctionIt = SecondaryEntryPointsMap.find(Address); + if (FunctionIt == SecondaryEntryPointsMap.end()) +return UINT_MAX; + const std::vector &Offsets = FunctionIt->second; auto OffsetIt = std::find(Offsets.begin(), Offsets.end(), Offset); if (OffsetIt == Offsets.end()) return UINT_MAX; diff --git a/bolt/lib/Profile/YAMLProfileWriter.cpp b/bolt/lib/Profile/YAMLProfileWriter.cpp index 78fb1e8539d477..bacee136de3f87 100644 --- a/bolt/lib/Profile/YAMLProfileWriter.cpp +++ b/bolt/lib/Profile/YAMLProfileWriter.cpp @@ -48,7 +48,8 @@ setCSIDestination(const BinaryContext &BC, yaml::bolt::CallSiteInfo &CSI, if (SymbolValue.getError()) return Callee; if (uint32_t Offset = SymbolValue.get() - Callee->getAddress()) - EntryID = (*GetBATSecondaryEntryPointId)(Callee->getAddress(), Offset); + EntryID = + (*GetBATSecondaryEntryPointId)(Callee->getAddress(), Offset) + 1; } else { BC.getFunctionForSymbol(Symbol, &EntryID); } >From 03520283ff38a47bc44cfa395534837d8da66934 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Thu, 28 Mar 2024 22:37:24 -0700 Subject: [PATCH 2/3] Fixed setting of BAT secondary entry point, updated test Created using spr 1.3.4 --- bolt/include/bolt/Profile/YAMLProfileWriter.h | 11 +-- bolt/lib/Profile/DataAggregator.cpp | 11 +-- bolt/lib/Profile/YAMLProfileWriter.cpp| 71 --- .../X86/yaml-secondary-entry-discriminator.s | 52 +- 4 files changed, 97 insertions(+), 48 deletions(-) diff --git a/bolt/include/bolt/Profile/YAMLProfileWriter.h b/bolt/include/bolt/Profile/YAMLProfileWriter.h index 7db581652a5b73..0db2e3fd90f9f1 100644 --- a/bolt/include/bolt/Profile/YAMLProfileWriter.h +++ b/bolt/include/bolt/Profile/YAMLProfileWriter.h @@ -15,6 +15,7 @@ namespace llvm { namespace bolt { +class BoltAddressTranslation; class RewriteInstance; class YAMLProfileWriter { @@ -31,17 +32,9 @@ class YAMLProfileWriter { /// Save execution profile for that instance. std::error_code writeProfile(const RewriteInstance &RI); - /// Callback to determine if a function is covered by BAT. - using IsBATCallbackTy = std::optional>; - /// Callback to get secondary entry point id for a given function and offset. - using GetBATSecondaryEntryPointIdCallbackTy = - std::optional>; - static yaml::bolt::BinaryFunctionProfile convert(const BinaryFunction &BF, bool UseDFS, - IsBATCallbackTy IsBATFunction = std::nullopt, - GetBATSecondaryEntryPointIdCallbackTy GetBATSecondaryEntryPointId = - std::nullopt); + const BoltAddressTranslation *BAT = nullptr); }; } // namespace bolt diff --git a/bolt/lib/Profile/DataAggregator.cpp b/bolt/lib/Profile/DataAggregator.cpp index 5b5ce5532ffdb9..71824e2cc0e97a 100644 --- a/bolt/lib/Profile/DataAggregator.cpp +++ b/bolt/lib/Profile/DataAggregator.cpp @@ -2324,13 +2324,6 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC, BP.Header.Flags = opts::BasicAggregation ? BinaryFunction::PF_SAMPLE : BinaryFunction::PF_LBR; - auto IsBATFunction = [&](uint64_t Address) { -return BAT->isBATFunction(Address); - }; - auto GetSecondaryEntryPointId = [&](uint64_t Address, uint32_t Offset) { -return BAT->getSecondaryEntryPointId(Address, Offset); - }; - if (!opts::BasicAggregation) { // Convert profile for functions not covered by BAT for (auto &BFI : BC.getBinaryFunctions()) { @@ -2339,8 +2332,8 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC, continue; if (BAT->isBATFunction(Function.getAddress())) continue; - BP.Functions.emplace_back(YAMLProfileWriter::convert( - Function, /*UseDFS=*/false, IsBATFunction, GetSecondaryEntryPointId)); + BP.Functions.emplace_back( + YAMLProfileWriter::convert(Function, /*UseDFS=*/false, BAT)); } for (const auto &KV : Names
[llvm-branch-commits] [llvm] [BOLT] Use BAT interfaces in YAMLProfileWriter::convert (PR #86219)
@@ -27,25 +28,55 @@ namespace bolt { /// Set CallSiteInfo destination fields from \p Symbol and return a target /// BinaryFunction for that symbol. -static const BinaryFunction *setCSIDestination(const BinaryContext &BC, - yaml::bolt::CallSiteInfo &CSI, - const MCSymbol *Symbol) { +static const BinaryFunction * +setCSIDestination(const BinaryContext &BC, yaml::bolt::CallSiteInfo &CSI, + const MCSymbol *Symbol, const BoltAddressTranslation *BAT) { CSI.DestId = 0; // designated for unknown functions CSI.EntryDiscriminator = 0; + auto setBATSecondaryEntry = [&](const BinaryFunction *const Callee) { +// The symbol could be a secondary entry in a cold fragment. +ErrorOr SymbolValue = BC.getSymbolValue(*Symbol); +if (SymbolValue.getError()) + return; + +// Containing function, not necessarily the same as symbol value. +const uint64_t CalleeAddress = Callee->getAddress(); +const uint32_t OutputOffset = SymbolValue.get() - CalleeAddress; + +const uint64_t ParentAddress = BAT->fetchParentAddress(CalleeAddress); +const uint64_t HotAddress = ParentAddress ? ParentAddress : CalleeAddress; + +if (const BinaryFunction *ParentBF = +BC.getBinaryFunctionAtAddress(HotAddress)) + CSI.DestId = ParentBF->getFunctionNumber(); + +const uint32_t InputOffset = +BAT->translate(CalleeAddress, OutputOffset, /*IsBranchSrc*/ false); + +if (!InputOffset) + return; + +CSI.EntryDiscriminator = +BAT->getSecondaryEntryPointId(HotAddress, InputOffset) + 1; + }; + if (Symbol) { uint64_t EntryID = 0; if (const BinaryFunction *const Callee = BC.getFunctionForSymbol(Symbol, &EntryID)) { CSI.DestId = Callee->getFunctionNumber(); CSI.EntryDiscriminator = EntryID; + if (BAT && BAT->isBATFunction(Callee->getAddress())) +setBATSecondaryEntry(Callee); aaupov wrote: Thanks, makes sense to do. 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] [llvm] [BOLT] Use BAT interfaces in YAMLProfileWriter::convert (PR #86219)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/86219 >From 685d3f5fa6ae75d6c3e22873a52ea8347e170c1e Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Thu, 28 Mar 2024 10:16:15 -0700 Subject: [PATCH 1/5] Get rid of std::map::at Created using spr 1.3.4 --- bolt/lib/Profile/BoltAddressTranslation.cpp | 5 - bolt/lib/Profile/YAMLProfileWriter.cpp | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/bolt/lib/Profile/BoltAddressTranslation.cpp b/bolt/lib/Profile/BoltAddressTranslation.cpp index 6d3f83efbe5f5a..7c54ba1971cbac 100644 --- a/bolt/lib/Profile/BoltAddressTranslation.cpp +++ b/bolt/lib/Profile/BoltAddressTranslation.cpp @@ -600,7 +600,10 @@ BoltAddressTranslation::getBFBranches(uint64_t OutputAddress) const { unsigned BoltAddressTranslation::getSecondaryEntryPointId(uint64_t Address, uint32_t Offset) const { - const std::vector &Offsets = SecondaryEntryPointsMap.at(Address); + auto FunctionIt = SecondaryEntryPointsMap.find(Address); + if (FunctionIt == SecondaryEntryPointsMap.end()) +return UINT_MAX; + const std::vector &Offsets = FunctionIt->second; auto OffsetIt = std::find(Offsets.begin(), Offsets.end(), Offset); if (OffsetIt == Offsets.end()) return UINT_MAX; diff --git a/bolt/lib/Profile/YAMLProfileWriter.cpp b/bolt/lib/Profile/YAMLProfileWriter.cpp index 78fb1e8539d477..bacee136de3f87 100644 --- a/bolt/lib/Profile/YAMLProfileWriter.cpp +++ b/bolt/lib/Profile/YAMLProfileWriter.cpp @@ -48,7 +48,8 @@ setCSIDestination(const BinaryContext &BC, yaml::bolt::CallSiteInfo &CSI, if (SymbolValue.getError()) return Callee; if (uint32_t Offset = SymbolValue.get() - Callee->getAddress()) - EntryID = (*GetBATSecondaryEntryPointId)(Callee->getAddress(), Offset); + EntryID = + (*GetBATSecondaryEntryPointId)(Callee->getAddress(), Offset) + 1; } else { BC.getFunctionForSymbol(Symbol, &EntryID); } >From 03520283ff38a47bc44cfa395534837d8da66934 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Thu, 28 Mar 2024 22:37:24 -0700 Subject: [PATCH 2/5] Fixed setting of BAT secondary entry point, updated test Created using spr 1.3.4 --- bolt/include/bolt/Profile/YAMLProfileWriter.h | 11 +-- bolt/lib/Profile/DataAggregator.cpp | 11 +-- bolt/lib/Profile/YAMLProfileWriter.cpp| 71 --- .../X86/yaml-secondary-entry-discriminator.s | 52 +- 4 files changed, 97 insertions(+), 48 deletions(-) diff --git a/bolt/include/bolt/Profile/YAMLProfileWriter.h b/bolt/include/bolt/Profile/YAMLProfileWriter.h index 7db581652a5b73..0db2e3fd90f9f1 100644 --- a/bolt/include/bolt/Profile/YAMLProfileWriter.h +++ b/bolt/include/bolt/Profile/YAMLProfileWriter.h @@ -15,6 +15,7 @@ namespace llvm { namespace bolt { +class BoltAddressTranslation; class RewriteInstance; class YAMLProfileWriter { @@ -31,17 +32,9 @@ class YAMLProfileWriter { /// Save execution profile for that instance. std::error_code writeProfile(const RewriteInstance &RI); - /// Callback to determine if a function is covered by BAT. - using IsBATCallbackTy = std::optional>; - /// Callback to get secondary entry point id for a given function and offset. - using GetBATSecondaryEntryPointIdCallbackTy = - std::optional>; - static yaml::bolt::BinaryFunctionProfile convert(const BinaryFunction &BF, bool UseDFS, - IsBATCallbackTy IsBATFunction = std::nullopt, - GetBATSecondaryEntryPointIdCallbackTy GetBATSecondaryEntryPointId = - std::nullopt); + const BoltAddressTranslation *BAT = nullptr); }; } // namespace bolt diff --git a/bolt/lib/Profile/DataAggregator.cpp b/bolt/lib/Profile/DataAggregator.cpp index 5b5ce5532ffdb9..71824e2cc0e97a 100644 --- a/bolt/lib/Profile/DataAggregator.cpp +++ b/bolt/lib/Profile/DataAggregator.cpp @@ -2324,13 +2324,6 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC, BP.Header.Flags = opts::BasicAggregation ? BinaryFunction::PF_SAMPLE : BinaryFunction::PF_LBR; - auto IsBATFunction = [&](uint64_t Address) { -return BAT->isBATFunction(Address); - }; - auto GetSecondaryEntryPointId = [&](uint64_t Address, uint32_t Offset) { -return BAT->getSecondaryEntryPointId(Address, Offset); - }; - if (!opts::BasicAggregation) { // Convert profile for functions not covered by BAT for (auto &BFI : BC.getBinaryFunctions()) { @@ -2339,8 +2332,8 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC, continue; if (BAT->isBATFunction(Function.getAddress())) continue; - BP.Functions.emplace_back(YAMLProfileWriter::convert( - Function, /*UseDFS=*/false, IsBATFunction, GetSecondaryEntryPointId)); + BP.Functions.emplace_back( + YAMLProfileWriter::convert(Function, /*UseDFS=*/false, BAT)); } for (const auto &KV : Names
[llvm-branch-commits] [llvm] [BOLT] Use BAT interfaces in YAMLProfileWriter::convert (PR #86219)
https://github.com/aaupov edited 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] [llvm] [BOLT] Use BAT interfaces in YAMLProfileWriter::convert (PR #86219)
https://github.com/aaupov edited 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] [llvm] [BOLT] Use BAT for YAML profile call target information (PR #86219)
https://github.com/aaupov edited 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][BAT] Fix handling of split functions (PR #87569)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/87569 ___ 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 handling of split functions (PR #87569)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/87569 ___ 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] Cover all call sites in writeBATYAML (PR #87743)
https://github.com/aaupov created https://github.com/llvm/llvm-project/pull/87743 Combine blocks from cold fragments in getBFBranches. Depends on https://github.com/llvm/llvm-project/pull/87569 Test Plan: Updated bolt/test/X86/yaml-secondary-entry-discriminator.s ___ 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 handling of split functions (PR #87569)
https://github.com/aaupov edited https://github.com/llvm/llvm-project/pull/87569 ___ 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 handling of split functions (PR #87569)
https://github.com/aaupov edited https://github.com/llvm/llvm-project/pull/87569 ___ 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 handling of split functions (PR #87569)
https://github.com/aaupov ready_for_review https://github.com/llvm/llvm-project/pull/87569 ___ 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] Cover all call sites in writeBATYAML (PR #87743)
https://github.com/aaupov edited https://github.com/llvm/llvm-project/pull/87743 ___ 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] Cover all call sites in writeBATYAML (PR #87743)
https://github.com/aaupov ready_for_review https://github.com/llvm/llvm-project/pull/87743 ___ 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] Cover all call sites in writeBATYAML (PR #87743)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/87743 >From 251020f10d1e6a7a888164748f78acc6994e0ab3 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Fri, 5 Apr 2024 07:36:40 -0700 Subject: [PATCH] Remove stats logging Created using spr 1.3.4 --- bolt/lib/Profile/DataAggregator.cpp | 13 - 1 file changed, 13 deletions(-) diff --git a/bolt/lib/Profile/DataAggregator.cpp b/bolt/lib/Profile/DataAggregator.cpp index 119d082c50c18c..1d0737167c808e 100644 --- a/bolt/lib/Profile/DataAggregator.cpp +++ b/bolt/lib/Profile/DataAggregator.cpp @@ -2395,19 +2395,6 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC, !YamlBB.CallSites.empty()) YamlBF.Blocks.emplace_back(YamlBB); } - - for (const auto &[BranchOffset, _] : Branches.InterIndex) { -bool Matched = -llvm::any_of(llvm::make_second_range(BFBranches), - [&](const std::vector &BranchOffsets) { - return llvm::is_contained(BranchOffsets, - BranchOffset); - }); -if (!Matched && opts::Verbosity >= 1) - errs() << "BOLT-WARNING: Couldn't match call site " - << formatv("{0}@{1:x} to YAML profile\n", FuncName, -BranchOffset); - } BP.Functions.emplace_back(YamlBF); } } ___ 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][BAT] Fix handling of split functions (PR #87569)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/87569 >From a3b0326428924a9565c673ffc6bc899ee788a19b Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Fri, 5 Apr 2024 07:40:41 -0700 Subject: [PATCH] Move comment to NumColdSamples Created using spr 1.3.4 --- bolt/include/bolt/Profile/DataAggregator.h | 4 1 file changed, 4 insertions(+) diff --git a/bolt/include/bolt/Profile/DataAggregator.h b/bolt/include/bolt/Profile/DataAggregator.h index 659a8488d1534c..3b8624585c19bd 100644 --- a/bolt/include/bolt/Profile/DataAggregator.h +++ b/bolt/include/bolt/Profile/DataAggregator.h @@ -225,6 +225,10 @@ class DataAggregator : public DataReader { /// Aggregation statistics uint64_t NumInvalidTraces{0}; uint64_t NumLongRangeTraces{0}; + /// Specifies how many samples were recorded in cold areas if we are dealing + /// with profiling data collected in a bolted binary. For LBRs, incremented + /// for the source of the branch to avoid counting cold activity twice (one + /// for source and another for destination). uint64_t NumColdSamples{0}; /// Looks into system PATH for Linux Perf and set up the aggregator to use it ___ 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][BAT] Fix handling of split functions (PR #87569)
https://github.com/aaupov edited https://github.com/llvm/llvm-project/pull/87569 ___ 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] Const-ify DataAggregator::getLocationName (PR #76908)
https://github.com/aaupov closed https://github.com/llvm/llvm-project/pull/76908 ___ 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] Const-ify DataAggregator::getLocationName (PR #76908)
aaupov wrote: Rolled into https://github.com/llvm/llvm-project/pull/87569 https://github.com/llvm/llvm-project/pull/76908 ___ 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/aaupov created https://github.com/llvm/llvm-project/pull/87830 Emit the recorded number of blocks, not the number of basic block hashes. There might be differences in corner cases (openssl BN_BLINDING_convert_ex function). Test Plan: Updated openssl.test in https://github.com/rafaelauler/bolt-tests/pull/31 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits