diff options
author | Mingming Liu <mingmingl@google.com> | 2024-02-07 20:03:44 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-07 20:03:44 -0800 |
commit | 05091aa3ac53a13d08c78882c0c2035e58a1b4c4 (patch) | |
tree | e1874996ddf2aa94d853812ab87a69cd3e12b934 /llvm | |
parent | d01864eb2f21d56cf432da7d80c505f510533c46 (diff) | |
download | llvm-05091aa3ac53a13d08c78882c0c2035e58a1b4c4.zip llvm-05091aa3ac53a13d08c78882c0c2035e58a1b4c4.tar.gz llvm-05091aa3ac53a13d08c78882c0c2035e58a1b4c4.tar.bz2 |
[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.
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/include/llvm/ProfileData/InstrProf.h | 2 | ||||
-rw-r--r-- | llvm/lib/ProfileData/InstrProf.cpp | 13 | ||||
-rw-r--r-- | llvm/tools/llvm-profdata/llvm-profdata.cpp | 2 | ||||
-rw-r--r-- | llvm/unittests/ProfileData/InstrProfTest.cpp | 6 |
4 files changed, 10 insertions, 13 deletions
diff --git a/llvm/include/llvm/ProfileData/InstrProf.h b/llvm/include/llvm/ProfileData/InstrProf.h index 87e7bbb..aa08e94 100644 --- a/llvm/include/llvm/ProfileData/InstrProf.h +++ b/llvm/include/llvm/ProfileData/InstrProf.h @@ -195,7 +195,7 @@ std::string getIRPGOFuncName(const Function &F, bool InLTO = false); /// \return the filename and the function name parsed from the output of /// \c getIRPGOFuncName() -std::pair<StringRef, StringRef> getParsedIRPGOFuncName(StringRef IRPGOFuncName); +std::pair<StringRef, StringRef> getParsedIRPGOName(StringRef IRPGOName); /// Return the name of the global variable used to store a function /// name in PGO instrumentation. \c FuncName is the IRPGO function name diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp index 2640027..d26004e 100644 --- a/llvm/lib/ProfileData/InstrProf.cpp +++ b/llvm/lib/ProfileData/InstrProf.cpp @@ -378,13 +378,12 @@ std::string getPGOFuncName(const Function &F, bool InLTO, uint64_t Version) { return getPGOFuncName(F.getName(), GlobalValue::ExternalLinkage, ""); } -// See getIRPGOFuncName() for a discription of the format. -std::pair<StringRef, StringRef> -getParsedIRPGOFuncName(StringRef IRPGOFuncName) { - auto [FileName, FuncName] = IRPGOFuncName.split(';'); - if (FuncName.empty()) - return std::make_pair(StringRef(), IRPGOFuncName); - return std::make_pair(FileName, FuncName); +// See getIRPGOObjectName() for a discription of the format. +std::pair<StringRef, StringRef> getParsedIRPGOName(StringRef IRPGOName) { + auto [FileName, MangledName] = IRPGOName.split(kGlobalIdentifierDelimiter); + if (MangledName.empty()) + return std::make_pair(StringRef(), IRPGOName); + return std::make_pair(FileName, MangledName); } StringRef getFuncNameWithoutPrefix(StringRef PGOFuncName, StringRef FileName) { diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp index 7754ca3..577a882 100644 --- a/llvm/tools/llvm-profdata/llvm-profdata.cpp +++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp @@ -3231,7 +3231,7 @@ static int order_main(int argc, const char *argv[]) { "-order_file.\n"; for (auto &N : Nodes) { auto [Filename, ParsedFuncName] = - getParsedIRPGOFuncName(Reader->getSymtab().getFuncOrVarName(N.Id)); + getParsedIRPGOName(Reader->getSymtab().getFuncOrVarName(N.Id)); if (!Filename.empty()) OS << "# " << Filename << "\n"; OS << ParsedFuncName << "\n"; diff --git a/llvm/unittests/ProfileData/InstrProfTest.cpp b/llvm/unittests/ProfileData/InstrProfTest.cpp index 8ffb68d..cd4552a 100644 --- a/llvm/unittests/ProfileData/InstrProfTest.cpp +++ b/llvm/unittests/ProfileData/InstrProfTest.cpp @@ -561,8 +561,7 @@ TEST_F(InstrProfTest, test_irpgo_function_name) { auto IRPGOFuncName = getIRPGOFuncName(*F); EXPECT_EQ(IRPGOFuncName, ExpectedIRPGOFuncName); - auto [Filename, ParsedIRPGOFuncName] = - getParsedIRPGOFuncName(IRPGOFuncName); + auto [Filename, ParsedIRPGOFuncName] = getParsedIRPGOName(IRPGOFuncName); StringRef ExpectedParsedIRPGOFuncName = IRPGOFuncName; if (ExpectedParsedIRPGOFuncName.consume_front("MyModule.cpp;")) { EXPECT_EQ(Filename, "MyModule.cpp"); @@ -1279,8 +1278,7 @@ TEST(SymtabTest, instr_prof_symtab_module_test) { auto IRPGOFuncName = ProfSymtab.getFuncOrVarName(IndexedInstrProf::ComputeHash(IRPGOName)); EXPECT_EQ(StringRef(IRPGOName), IRPGOFuncName); - EXPECT_EQ(StringRef(Funcs[I]), - getParsedIRPGOFuncName(IRPGOFuncName).second); + EXPECT_EQ(StringRef(Funcs[I]), getParsedIRPGOName(IRPGOFuncName).second); // Ensure we can still read this old record name. std::string PGOName = getPGOFuncName(*F); auto PGOFuncName = |