[PATCH] D142269: [BOLT] Use LTO fuzzy name matching in function-order=user
Amir Ayupov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 20 19:56:40 PST 2023
Amir created this revision.
Amir added a reviewer: bolt.
Herald added subscribers: treapster, ayermolo, inglorion.
Herald added a reviewer: rafauler.
Herald added a reviewer: maksfb.
Herald added a project: All.
Amir requested review of this revision.
Herald added subscribers: llvm-commits, yota9.
Herald added a project: LLVM.
TBD
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D142269
Files:
bolt/lib/Passes/ReorderFunctions.cpp
Index: bolt/lib/Passes/ReorderFunctions.cpp
===================================================================
--- bolt/lib/Passes/ReorderFunctions.cpp
+++ bolt/lib/Passes/ReorderFunctions.cpp
@@ -12,6 +12,8 @@
#include "bolt/Passes/ReorderFunctions.h"
#include "bolt/Passes/HFSort.h"
+#include "bolt/Utils/Utils.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/CommandLine.h"
#include <fstream>
@@ -327,15 +329,22 @@
break;
case RT_USER:
{
+ // Build LTOCommonNameMap
+ StringMap<std::vector<uint64_t>> LTOCommonNameMap;
+ for (const BinaryFunction &BF : llvm::make_second_range(BFs))
+ for (StringRef Name : BF.getNames())
+ if (std::optional<StringRef> LTOCommonName = getLTOCommonName(Name))
+ LTOCommonNameMap[*LTOCommonName].push_back(BF.getAddress());
+
uint32_t Index = 0;
for (const std::string &Function : readFunctionOrderFile()) {
std::vector<uint64_t> FuncAddrs;
BinaryData *BD = BC.getBinaryDataByName(Function);
if (!BD) {
+ // If we can't find the main symbol name, look for alternates.
uint32_t LocalID = 1;
while (true) {
- // If we can't find the main symbol name, look for alternates.
const std::string FuncName =
Function + "/" + std::to_string(LocalID);
BD = BC.getBinaryDataByName(FuncName);
@@ -345,6 +354,10 @@
break;
LocalID++;
}
+ // Strip LTO suffixes
+ if (std::optional<StringRef> CommonName = getLTOCommonName(Function))
+ if (LTOCommonNameMap.find(*CommonName) != LTOCommonNameMap.end())
+ llvm::append_range(FuncAddrs, LTOCommonNameMap[*CommonName]);
} else {
FuncAddrs.push_back(BD->getAddress());
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142269.491023.patch
Type: text/x-patch
Size: 1846 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230121/b1d73c5b/attachment.bin>
More information about the llvm-commits
mailing list