@@ -20,10 +20,9 @@ namespace bolt {
20
20
21
21
const char *BoltAddressTranslation::SECTION_NAME = " .note.bolt_bat" ;
22
22
23
- void BoltAddressTranslation::writeEntriesForBB (MapTy &Map,
24
- const BinaryBasicBlock &BB,
25
- uint64_t FuncInputAddress,
26
- uint64_t FuncOutputAddress) {
23
+ void BoltAddressTranslation::writeEntriesForBB (
24
+ MapTy &Map, const BinaryBasicBlock &BB, uint64_t FuncInputAddress,
25
+ uint64_t FuncOutputAddress) const {
27
26
const uint64_t BBOutputOffset =
28
27
BB.getOutputAddressRange ().first - FuncOutputAddress;
29
28
const uint32_t BBInputOffset = BB.getInputOffset ();
@@ -138,8 +137,8 @@ void BoltAddressTranslation::write(const BinaryContext &BC, raw_ostream &OS) {
138
137
<< " basic block hashes\n " ;
139
138
}
140
139
141
- APInt BoltAddressTranslation::calculateBranchEntriesBitMask (MapTy &Map,
142
- size_t EqualElems) {
140
+ APInt BoltAddressTranslation::calculateBranchEntriesBitMask (
141
+ MapTy &Map, size_t EqualElems) const {
143
142
APInt BitMask (alignTo (EqualElems, 8 ), 0 );
144
143
size_t Index = 0 ;
145
144
for (std::pair<const uint32_t , uint32_t > &KeyVal : Map) {
@@ -422,7 +421,7 @@ void BoltAddressTranslation::parseMaps(std::vector<uint64_t> &HotFuncs,
422
421
}
423
422
}
424
423
425
- void BoltAddressTranslation::dump (raw_ostream &OS) {
424
+ void BoltAddressTranslation::dump (raw_ostream &OS) const {
426
425
const size_t NumTables = Maps.size ();
427
426
OS << " BAT tables for " << NumTables << " functions:\n " ;
428
427
for (const auto &MapEntry : Maps) {
@@ -447,11 +446,15 @@ void BoltAddressTranslation::dump(raw_ostream &OS) {
447
446
OS << formatv (" hash: {0:x}" , BBHashMap.getBBHash (Val));
448
447
OS << " \n " ;
449
448
}
450
- if (IsHotFunction)
451
- OS << " NumBlocks: " << NumBasicBlocksMap[Address] << ' \n ' ;
452
- if (SecondaryEntryPointsMap.count (Address)) {
449
+ if (IsHotFunction) {
450
+ auto NumBasicBlocksIt = NumBasicBlocksMap.find (Address);
451
+ assert (NumBasicBlocksIt != NumBasicBlocksMap.end ());
452
+ OS << " NumBlocks: " << NumBasicBlocksIt->second << ' \n ' ;
453
+ }
454
+ auto SecondaryEntryPointsIt = SecondaryEntryPointsMap.find (Address);
455
+ if (SecondaryEntryPointsIt != SecondaryEntryPointsMap.end ()) {
453
456
const std::vector<uint32_t > &SecondaryEntryPoints =
454
- SecondaryEntryPointsMap[Address] ;
457
+ SecondaryEntryPointsIt-> second ;
455
458
OS << SecondaryEntryPoints.size () << " secondary entry points:\n " ;
456
459
for (uint32_t EntryPointOffset : SecondaryEntryPoints)
457
460
OS << formatv (" {0:x}\n " , EntryPointOffset);
0 commit comments