-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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.
@llvm/pr-subscribers-pgo Author: Mingming Liu (minglotus-6) Changes
Full diff: https://github.com/llvm/llvm-project/pull/81054.diff 4 Files Affected:
diff --git a/llvm/include/llvm/ProfileData/InstrProf.h b/llvm/include/llvm/ProfileData/InstrProf.h
index 87e7bbbd727ee..aa08e949b5eaf 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 2640027455e0d..b4dd0c202a5c7 100644
--- a/llvm/lib/ProfileData/InstrProf.cpp
+++ b/llvm/lib/ProfileData/InstrProf.cpp
@@ -380,11 +380,11 @@ std::string getPGOFuncName(const Function &F, bool InLTO, uint64_t Version) {
// 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);
+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 e6dc81ba1f5b0..38ae5e65220b6 100644
--- a/llvm/tools/llvm-profdata/llvm-profdata.cpp
+++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp
@@ -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";
diff --git a/llvm/unittests/ProfileData/InstrProfTest.cpp b/llvm/unittests/ProfileData/InstrProfTest.cpp
index 8ffb68de7a2d2..76505aea1c998 100644
--- a/llvm/unittests/ProfileData/InstrProfTest.cpp
+++ b/llvm/unittests/ProfileData/InstrProfTest.cpp
@@ -562,7 +562,7 @@ TEST_F(InstrProfTest, test_irpgo_function_name) {
EXPECT_EQ(IRPGOFuncName, ExpectedIRPGOFuncName);
auto [Filename, ParsedIRPGOFuncName] =
- getParsedIRPGOFuncName(IRPGOFuncName);
+ getParsedIRPGOName(IRPGOFuncName);
StringRef ExpectedParsedIRPGOFuncName = IRPGOFuncName;
if (ExpectedParsedIRPGOFuncName.consume_front("MyModule.cpp;")) {
EXPECT_EQ(Filename, "MyModule.cpp");
@@ -1280,7 +1280,7 @@ TEST(SymtabTest, instr_prof_symtab_module_test) {
ProfSymtab.getFuncOrVarName(IndexedInstrProf::ComputeHash(IRPGOName));
EXPECT_EQ(StringRef(IRPGOName), IRPGOFuncName);
EXPECT_EQ(StringRef(Funcs[I]),
- getParsedIRPGOFuncName(IRPGOFuncName).second);
+ getParsedIRPGOName(IRPGOFuncName).second);
// Ensure we can still read this old record name.
std::string PGOName = getPGOFuncName(*F);
auto PGOFuncName =
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
ellishg
approved these changes
Feb 7, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
david-xl
approved these changes
Feb 7, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[filename;]mangled-name
format could be generalized for non-function global values (e.g., vtables for type profiling). So rename the function.