[BOLT][BAT] Fix encoded NumBasicBlocks
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 Reviewers: rafaelauler, ayermolo, maksfb, dcci Reviewed By: ayermolo Pull Request: https://github.com/llvm/llvm-project/pull/87830
This commit is contained in:
@@ -208,7 +208,7 @@ void BoltAddressTranslation::writeMaps(std::map<uint64_t, MapTy> &Maps,
|
||||
LLVM_DEBUG(dbgs() << "Hash: " << formatv("{0:x}\n", BFHash));
|
||||
OS.write(reinterpret_cast<char *>(&BFHash), 8);
|
||||
// Number of basic blocks
|
||||
size_t NumBasicBlocks = getBBHashMap(HotInputAddress).getNumBasicBlocks();
|
||||
size_t NumBasicBlocks = NumBasicBlocksMap[HotInputAddress];
|
||||
LLVM_DEBUG(dbgs() << "Basic blocks: " << NumBasicBlocks << '\n');
|
||||
encodeULEB128(NumBasicBlocks, OS);
|
||||
// Secondary entry points
|
||||
@@ -426,8 +426,9 @@ void BoltAddressTranslation::dump(raw_ostream &OS) {
|
||||
for (const auto &MapEntry : Maps) {
|
||||
const uint64_t Address = MapEntry.first;
|
||||
const uint64_t HotAddress = fetchParentAddress(Address);
|
||||
const bool IsHotFunction = HotAddress == 0;
|
||||
OS << "Function Address: 0x" << Twine::utohexstr(Address);
|
||||
if (HotAddress == 0)
|
||||
if (IsHotFunction)
|
||||
OS << formatv(", hash: {0:x}", getBFHash(Address));
|
||||
OS << "\n";
|
||||
OS << "BB mappings:\n";
|
||||
@@ -444,6 +445,8 @@ void BoltAddressTranslation::dump(raw_ostream &OS) {
|
||||
OS << formatv(" hash: {0:x}", BBHashMap.getBBHash(Val));
|
||||
OS << "\n";
|
||||
}
|
||||
if (IsHotFunction)
|
||||
OS << "NumBlocks: " << NumBasicBlocksMap[Address] << '\n';
|
||||
if (SecondaryEntryPointsMap.count(Address)) {
|
||||
const std::vector<uint32_t> &SecondaryEntryPoints =
|
||||
SecondaryEntryPointsMap[Address];
|
||||
@@ -575,6 +578,7 @@ void BoltAddressTranslation::saveMetadata(BinaryContext &BC) {
|
||||
// Set BF/BB metadata
|
||||
for (const BinaryBasicBlock &BB : BF)
|
||||
BBHashMap.addEntry(BB.getInputOffset(), BB.getIndex(), BB.getHash());
|
||||
NumBasicBlocksMap.emplace(BF.getAddress(), BF.size());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user