Skip to content

Commit 05091aa

Browse files
[NFC][InstrProf]Generalize getParsedIRPGOFuncName to getParsedIRPGOName (#81054)
- Function getParsedIRPGOFuncName splits name by delimiter. The `[filename;]mangled-name` format could be generalized for non-function global values (e.g., vtables for type profiling). So rename the function. - Use kGlobalIdentifierDelimiter rather than semicolon directly for defragmentation.
1 parent d01864e commit 05091aa

File tree

4 files changed

+10
-13
lines changed

4 files changed

+10
-13
lines changed

llvm/include/llvm/ProfileData/InstrProf.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ std::string getIRPGOFuncName(const Function &F, bool InLTO = false);
195195

196196
/// \return the filename and the function name parsed from the output of
197197
/// \c getIRPGOFuncName()
198-
std::pair<StringRef, StringRef> getParsedIRPGOFuncName(StringRef IRPGOFuncName);
198+
std::pair<StringRef, StringRef> getParsedIRPGOName(StringRef IRPGOName);
199199

200200
/// Return the name of the global variable used to store a function
201201
/// name in PGO instrumentation. \c FuncName is the IRPGO function name

llvm/lib/ProfileData/InstrProf.cpp

+6-7
Original file line numberDiff line numberDiff line change
@@ -378,13 +378,12 @@ std::string getPGOFuncName(const Function &F, bool InLTO, uint64_t Version) {
378378
return getPGOFuncName(F.getName(), GlobalValue::ExternalLinkage, "");
379379
}
380380

381-
// See getIRPGOFuncName() for a discription of the format.
382-
std::pair<StringRef, StringRef>
383-
getParsedIRPGOFuncName(StringRef IRPGOFuncName) {
384-
auto [FileName, FuncName] = IRPGOFuncName.split(';');
385-
if (FuncName.empty())
386-
return std::make_pair(StringRef(), IRPGOFuncName);
387-
return std::make_pair(FileName, FuncName);
381+
// See getIRPGOObjectName() for a discription of the format.
382+
std::pair<StringRef, StringRef> getParsedIRPGOName(StringRef IRPGOName) {
383+
auto [FileName, MangledName] = IRPGOName.split(kGlobalIdentifierDelimiter);
384+
if (MangledName.empty())
385+
return std::make_pair(StringRef(), IRPGOName);
386+
return std::make_pair(FileName, MangledName);
388387
}
389388

390389
StringRef getFuncNameWithoutPrefix(StringRef PGOFuncName, StringRef FileName) {

llvm/tools/llvm-profdata/llvm-profdata.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3231,7 +3231,7 @@ static int order_main(int argc, const char *argv[]) {
32313231
"-order_file.\n";
32323232
for (auto &N : Nodes) {
32333233
auto [Filename, ParsedFuncName] =
3234-
getParsedIRPGOFuncName(Reader->getSymtab().getFuncOrVarName(N.Id));
3234+
getParsedIRPGOName(Reader->getSymtab().getFuncOrVarName(N.Id));
32353235
if (!Filename.empty())
32363236
OS << "# " << Filename << "\n";
32373237
OS << ParsedFuncName << "\n";

llvm/unittests/ProfileData/InstrProfTest.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -561,8 +561,7 @@ TEST_F(InstrProfTest, test_irpgo_function_name) {
561561
auto IRPGOFuncName = getIRPGOFuncName(*F);
562562
EXPECT_EQ(IRPGOFuncName, ExpectedIRPGOFuncName);
563563

564-
auto [Filename, ParsedIRPGOFuncName] =
565-
getParsedIRPGOFuncName(IRPGOFuncName);
564+
auto [Filename, ParsedIRPGOFuncName] = getParsedIRPGOName(IRPGOFuncName);
566565
StringRef ExpectedParsedIRPGOFuncName = IRPGOFuncName;
567566
if (ExpectedParsedIRPGOFuncName.consume_front("MyModule.cpp;")) {
568567
EXPECT_EQ(Filename, "MyModule.cpp");
@@ -1279,8 +1278,7 @@ TEST(SymtabTest, instr_prof_symtab_module_test) {
12791278
auto IRPGOFuncName =
12801279
ProfSymtab.getFuncOrVarName(IndexedInstrProf::ComputeHash(IRPGOName));
12811280
EXPECT_EQ(StringRef(IRPGOName), IRPGOFuncName);
1282-
EXPECT_EQ(StringRef(Funcs[I]),
1283-
getParsedIRPGOFuncName(IRPGOFuncName).second);
1281+
EXPECT_EQ(StringRef(Funcs[I]), getParsedIRPGOName(IRPGOFuncName).second);
12841282
// Ensure we can still read this old record name.
12851283
std::string PGOName = getPGOFuncName(*F);
12861284
auto PGOFuncName =

0 commit comments

Comments
 (0)