Skip to content

Commit 4f12766

Browse files
authored
[BOLT] Set entry counts in BAT YAML profile (#91775)
Align with DataReader::readProfile that sets entry block counts from FuncBranchData->EntryData. Test Plan: updated bolt-address-translation-yaml.test
1 parent bbcdd4f commit 4f12766

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2403,6 +2403,17 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC,
24032403
return A.Offset < B.Offset;
24042404
});
24052405
}
2406+
// Set entry counts, similar to DataReader::readProfile.
2407+
for (const llvm::bolt::BranchInfo &BI : Branches.EntryData) {
2408+
if (!BlockMap.isInputBlock(BI.To.Offset)) {
2409+
if (opts::Verbosity >= 1)
2410+
errs() << "BOLT-WARNING: Unexpected EntryData in " << FuncName
2411+
<< " at 0x" << Twine::utohexstr(BI.To.Offset) << '\n';
2412+
continue;
2413+
}
2414+
const unsigned BlockIndex = BlockMap.getBBIndex(BI.To.Offset);
2415+
YamlBF.Blocks[BlockIndex].ExecCount += BI.Branches;
2416+
}
24062417
// Drop blocks without a hash, won't be useful for stale matching.
24072418
llvm::erase_if(YamlBF.Blocks,
24082419
[](const yaml::bolt::BinaryBasicBlockProfile &YamlBB) {

bolt/test/X86/bolt-address-translation-yaml.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ YAML-BAT-CHECK-NEXT: hash: 0x6AF7E61EA3966722
4848
YAML-BAT-CHECK-NEXT: exec: 25
4949
YAML-BAT-CHECK-NEXT: nblocks: 15
5050
YAML-BAT-CHECK-NEXT: blocks:
51+
YAML-BAT-CHECK-NEXT: - bid: 0
52+
YAML-BAT-CHECK-NEXT: insns: [[#]]
53+
YAML-BAT-CHECK-NEXT: hash: 0x700F19D24600000
54+
YAML-BAT-CHECK-NEXT: exec: 25
5155
YAML-BAT-CHECK: - bid: 3
5256
YAML-BAT-CHECK-NEXT: insns: [[#]]
5357
YAML-BAT-CHECK-NEXT: hash: 0xDDA1DC5F69F900AC

0 commit comments

Comments
 (0)