[llvm-branch-commits] [clang] [lldb] [libcxx] [mlir] [openmp] [clang-tools-extra] [flang] [libc] [llvm] [BOLT] Deduplicate equal offsets in BAT (PR #76905)
Amir Ayupov via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Jan 18 13:34:32 PST 2024
================
@@ -110,6 +111,34 @@ void BoltAddressTranslation::write(const BinaryContext &BC, raw_ostream &OS) {
outs() << "BOLT-INFO: Wrote " << Maps.size() << " BAT maps\n";
}
+APInt BoltAddressTranslation::calculateBranchEntriesBitMask(MapTy &Map,
+ size_t EqualElems) {
+ APInt BitMask(alignTo(EqualElems, 8), 0);
+ size_t Index = 0;
+ for (std::pair<const uint32_t, uint32_t> &KeyVal : Map) {
+ if (Index == EqualElems)
+ break;
+ const uint32_t OutputOffset = KeyVal.second;
+ if (OutputOffset & BRANCHENTRY)
+ BitMask.setBit(Index);
+ ++Index;
+ }
+ return BitMask;
+}
+
+size_t BoltAddressTranslation::getNumEqualOffsets(const MapTy &Map) const {
+ size_t EqualOffsets = 0;
+ for (const std::pair<const uint32_t, uint32_t> &KeyVal : Map) {
+ const uint32_t OutputOffset = KeyVal.first;
+ const uint32_t InputOffset = KeyVal.second >> 1;
+ if (OutputOffset == InputOffset)
+ ++EqualOffsets;
+ else
+ break;
----------------
aaupov wrote:
Yes, that's by design. The idea is that if OutputOffset==InputOffset, only emit one of them. It's expected that if offsets start to diverge at some point, they're not reconverging.
https://github.com/llvm/llvm-project/pull/76905
More information about the llvm-branch-commits
mailing list