Skip to content

[NFC][InstrProf]Generalize getParsedIRPGOFuncName to getParsedIRPGOName #81054

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/include/llvm/ProfileData/InstrProf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 6 additions & 7 deletions llvm/lib/ProfileData/InstrProf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-profdata/llvm-profdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3164,7 +3164,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";
Expand Down
6 changes: 2 additions & 4 deletions llvm/unittests/ProfileData/InstrProfTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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 =
Expand Down