@@ -45,8 +45,6 @@ void BoltAddressTranslation::writeEntriesForBB(MapTy &Map,
45
45
LLVM_DEBUG (dbgs () << formatv (" Hash: {0:x}\n " ,
46
46
getBBHash (HotFuncAddress, BBInputOffset)));
47
47
(void )HotFuncAddress;
48
- LLVM_DEBUG (dbgs () << formatv (" Index: {0}\n " ,
49
- getBBIndex (HotFuncAddress, BBInputOffset)));
50
48
// In case of conflicts (same Key mapping to different Vals), the last
51
49
// update takes precedence. Of course it is not ideal to have conflicts and
52
50
// those happen when we have an empty BB that either contained only
@@ -219,7 +217,6 @@ void BoltAddressTranslation::writeMaps(std::map<uint64_t, MapTy> &Maps,
219
217
}
220
218
size_t Index = 0 ;
221
219
uint64_t InOffset = 0 ;
222
- size_t PrevBBIndex = 0 ;
223
220
// Output and Input addresses and delta-encoded
224
221
for (std::pair<const uint32_t , uint32_t > &KeyVal : Map) {
225
222
const uint64_t OutputAddress = KeyVal.first + Address;
@@ -229,15 +226,11 @@ void BoltAddressTranslation::writeMaps(std::map<uint64_t, MapTy> &Maps,
229
226
encodeSLEB128 (KeyVal.second - InOffset, OS);
230
227
InOffset = KeyVal.second ; // Keeping InOffset as if BRANCHENTRY is encoded
231
228
if ((InOffset & BRANCHENTRY) == 0 ) {
232
- unsigned BBIndex;
233
- size_t BBHash;
234
- std::tie (BBIndex, BBHash) = FuncHashPair.second [InOffset >> 1 ];
229
+ // Basic block hash
230
+ size_t BBHash = FuncHashPair.second [InOffset >> 1 ];
235
231
OS.write (reinterpret_cast <char *>(&BBHash), 8 );
236
- // Basic block index in the input binary
237
- encodeULEB128 (BBIndex - PrevBBIndex, OS);
238
- PrevBBIndex = BBIndex;
239
- LLVM_DEBUG (dbgs () << formatv (" {0:x} -> {1:x} {2:x} {3}\n " , KeyVal.first ,
240
- InOffset >> 1 , BBHash, BBIndex));
232
+ LLVM_DEBUG (dbgs () << formatv (" {0:x} -> {1:x} {2:x}\n " , KeyVal.first ,
233
+ InOffset >> 1 , BBHash));
241
234
}
242
235
}
243
236
}
@@ -323,7 +316,6 @@ void BoltAddressTranslation::parseMaps(std::vector<uint64_t> &HotFuncs,
323
316
LLVM_DEBUG (dbgs () << " Parsing " << NumEntries << " entries for 0x"
324
317
<< Twine::utohexstr (Address) << " \n " );
325
318
uint64_t InputOffset = 0 ;
326
- size_t BBIndex = 0 ;
327
319
for (uint32_t J = 0 ; J < NumEntries; ++J) {
328
320
const uint64_t OutputDelta = DE.getULEB128 (&Offset, &Err);
329
321
const uint64_t OutputAddress = PrevAddress + OutputDelta;
@@ -338,25 +330,19 @@ void BoltAddressTranslation::parseMaps(std::vector<uint64_t> &HotFuncs,
338
330
}
339
331
Map.insert (std::pair<uint32_t , uint32_t >(OutputOffset, InputOffset));
340
332
size_t BBHash = 0 ;
341
- size_t BBIndexDelta = 0 ;
342
333
const bool IsBranchEntry = InputOffset & BRANCHENTRY;
343
334
if (!IsBranchEntry) {
344
335
BBHash = DE.getU64 (&Offset, &Err);
345
- BBIndexDelta = DE.getULEB128 (&Offset, &Err);
346
- BBIndex += BBIndexDelta;
347
336
// Map basic block hash to hot fragment by input offset
348
- FuncHashes[HotAddress].second .emplace (InputOffset >> 1 ,
349
- std::pair (BBIndex, BBHash));
337
+ FuncHashes[HotAddress].second .emplace (InputOffset >> 1 , BBHash);
350
338
}
351
339
LLVM_DEBUG ({
352
340
dbgs () << formatv (
353
341
" {0:x} -> {1:x} ({2}/{3}b -> {4}/{5}b), {6:x}" , OutputOffset,
354
342
InputOffset, OutputDelta, getULEB128Size (OutputDelta), InputDelta,
355
343
(J < EqualElems) ? 0 : getSLEB128Size (InputDelta), OutputAddress);
356
- if (!IsBranchEntry) {
357
- dbgs () << formatv (" {0:x} {1}/{2}b" , BBHash, BBIndex,
358
- getULEB128Size (BBIndexDelta));
359
- }
344
+ if (BBHash)
345
+ dbgs () << formatv (" {0:x}" , BBHash);
360
346
dbgs () << ' \n ' ;
361
347
});
362
348
}
@@ -508,19 +494,14 @@ void BoltAddressTranslation::saveMetadata(BinaryContext &BC) {
508
494
FuncHashes[BF.getAddress ()].first = BF.computeHash ();
509
495
BF.computeBlockHashes ();
510
496
for (const BinaryBasicBlock &BB : BF)
511
- FuncHashes[BF.getAddress ()].second .emplace (
512
- BB. getInputOffset (), std::pair (BB. getIndex (), BB.getHash () ));
497
+ FuncHashes[BF.getAddress ()].second .emplace (BB. getInputOffset (),
498
+ BB.getHash ());
513
499
}
514
500
}
515
501
516
- unsigned BoltAddressTranslation::getBBIndex (uint64_t FuncOutputAddress,
517
- uint32_t BBInputOffset) const {
518
- return FuncHashes.at (FuncOutputAddress).second .at (BBInputOffset).first ;
519
- }
520
-
521
502
size_t BoltAddressTranslation::getBBHash (uint64_t FuncOutputAddress,
522
503
uint32_t BBInputOffset) const {
523
- return FuncHashes.at (FuncOutputAddress).second .at (BBInputOffset). second ;
504
+ return FuncHashes.at (FuncOutputAddress).second .at (BBInputOffset);
524
505
}
525
506
526
507
size_t BoltAddressTranslation::getBFHash (uint64_t OutputAddress) const {
0 commit comments