[BOLT] Track fragment info for all split fragments
To generate all symbols correctly, it is necessary to record the address of each fragment. This patch moves the address info for the main and cold fragments from BinaryFunction to FunctionFragment, where this data is recorded for all fragments. Reviewed By: rafauler Differential Revision: https://reviews.llvm.org/D132051
This commit is contained in:
@@ -73,29 +73,27 @@ void BoltAddressTranslation::write(const BinaryContext &BC, raw_ostream &OS) {
|
||||
LLVM_DEBUG(dbgs() << "Function name: " << Function.getPrintName() << "\n");
|
||||
LLVM_DEBUG(dbgs() << " Address reference: 0x"
|
||||
<< Twine::utohexstr(Function.getOutputAddress()) << "\n");
|
||||
MapTy Map;
|
||||
const bool IsSplit = Function.isSplit();
|
||||
for (const BinaryBasicBlock *const BB : Function.getLayout().blocks()) {
|
||||
if (IsSplit && BB->isCold())
|
||||
break;
|
||||
writeEntriesForBB(Map, *BB, Function.getOutputAddress());
|
||||
}
|
||||
Maps.insert(std::pair<uint64_t, MapTy>(Function.getOutputAddress(), Map));
|
||||
|
||||
if (!IsSplit)
|
||||
MapTy Map;
|
||||
for (const BinaryBasicBlock *const BB :
|
||||
Function.getLayout().getMainFragment())
|
||||
writeEntriesForBB(Map, *BB, Function.getOutputAddress());
|
||||
Maps.emplace(Function.getOutputAddress(), std::move(Map));
|
||||
|
||||
if (!Function.isSplit())
|
||||
continue;
|
||||
|
||||
// Cold map
|
||||
Map.clear();
|
||||
// Split maps
|
||||
LLVM_DEBUG(dbgs() << " Cold part\n");
|
||||
for (const BinaryBasicBlock *const BB : Function.getLayout().blocks()) {
|
||||
if (!BB->isCold())
|
||||
continue;
|
||||
writeEntriesForBB(Map, *BB, Function.cold().getAddress());
|
||||
for (const FunctionFragment &FF :
|
||||
Function.getLayout().getSplitFragments()) {
|
||||
Map.clear();
|
||||
for (const BinaryBasicBlock *const BB : FF)
|
||||
writeEntriesForBB(Map, *BB, FF.getAddress());
|
||||
|
||||
Maps.emplace(FF.getAddress(), std::move(Map));
|
||||
ColdPartSource.emplace(FF.getAddress(), Function.getOutputAddress());
|
||||
}
|
||||
Maps.insert(std::pair<uint64_t, MapTy>(Function.cold().getAddress(), Map));
|
||||
ColdPartSource.insert(std::pair<uint64_t, uint64_t>(
|
||||
Function.cold().getAddress(), Function.getOutputAddress()));
|
||||
}
|
||||
|
||||
const uint32_t NumFuncs = Maps.size();
|
||||
|
||||
Reference in New Issue
Block a user