Skip to content
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

[BasicBlockSections] Introduce the basic block sections profile version 1. #65506

Merged
merged 4 commits into from
Sep 22, 2023

Conversation

rlavaee
Copy link
Contributor

@rlavaee rlavaee commented Sep 6, 2023

This patch introduces a new version for the basic block sections profile as was requested in D158442, while keeping backward compatibility for the old version.

The new encoding is as follows:

m <module_name>
f <function_name_1> <function_name_2>...
c <bb_id_1> <bb_id_2> <bb_id_3>
c <bb_id_4> <bb_id_5>
...

Module name specifier (starting with 'm') is optional and allows distinguishing profiles for internal-linkage functions with the same name. If not specified, profile will be applied to any function with the same name.
Function name specifier (starting with 'f') can specify multiple function name aliases.
Finally, basic block clusters are specified by 'c' and specify the cluster of basic blocks, and the internal order in which they must be placed in the same section.

Copy link
Contributor

@shenhanc78 shenhanc78 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f <function name 1> <function name 2>
So func name 1 and func name 2 are aliaes, right?

@rlavaee rlavaee requested review from a team as code owners September 8, 2023 18:48
@rlavaee rlavaee removed PGO Profile Guided Optimizations flang Flang issues not falling into any other category LTO Link time optimization (regular/full LTO or ThinLTO) clang:dataflow Clang Dataflow Analysis framework - https://clang.llvm.org/docs/DataFlowAnalysisIntro.html backend:loongarch llvm:SelectionDAG SelectionDAGISel as well llvm-lit mlir:ods flang:openmp llvm:ir testing-tools openacc labels Sep 8, 2023
@rlavaee
Copy link
Contributor Author

rlavaee commented Sep 8, 2023

f <function name 1> <function name 2> So func name 1 and func name 2 are aliaes, right?

Correct. Fixed the function comment.

@rlavaee rlavaee closed this Sep 8, 2023
@rlavaee rlavaee reopened this Sep 8, 2023
@rlavaee rlavaee dismissed asl’s stale review September 8, 2023 19:27

Sorry. Fixed the pr. Still learning...

@rlavaee
Copy link
Contributor Author

rlavaee commented Sep 14, 2023

ping. @tmsri

@rlavaee
Copy link
Contributor Author

rlavaee commented Sep 19, 2023

Another friendly ping for review.

…on 1. llvm#65506

This patch introduces a new version for the basic block sections profile as was requested in D158442, while keeping backward compatibility for the old version.

The new encoding is as follows:

m <module_name>
f <function_name_1> <function_name_2>...
c <bb_id_1> <bb_id_2> <bb_id_3>
c <bb_id_4> <bb_id_5>
...
Module name specifier (starting with 'm') is optional and allows distinguishing profiles for internal-linkage functions with the same name. If not specified, profile will be applied to any function with the same name.
Function name specifier (starting with 'f') can specify multiple function name aliases.
Finally, basic block clusters are specified by 'c' and specify the cluster of basic blocks, and the internal order in which they must be placed in the same section.
@rlavaee rlavaee merged commit 6ac71a0 into llvm:main Sep 22, 2023
2 of 3 checks passed
@github-actions
Copy link

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff 46d5d264fc66a017bbd0182b2b5fcc0f3f23d3be 8a1893b39119166b6de06c1d182b967015518c3c -- llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h llvm/lib/CodeGen/BasicBlockSectionsProfileReader.cpp
View the diff from clang-format here.
diff --git a/llvm/lib/CodeGen/BasicBlockSectionsProfileReader.cpp b/llvm/lib/CodeGen/BasicBlockSectionsProfileReader.cpp
index 30f0cbd25316..ef5f1251f532 100644
--- a/llvm/lib/CodeGen/BasicBlockSectionsProfileReader.cpp
+++ b/llvm/lib/CodeGen/BasicBlockSectionsProfileReader.cpp
@@ -86,14 +86,14 @@ Error BasicBlockSectionsProfileReader::ReadV1Profile() {
     switch (Specifier) {
     case '@':
       break;
-    case 'm':  // Module name speicifer.
+    case 'm': // Module name speicifer.
       if (Values.size() != 1) {
         return createProfileParseError(Twine("invalid module name value: '") +
                                        S + "'");
       }
       DIFilename = sys::path::remove_leading_dotslash(Values[0]);
       continue;
-    case 'f': {  // Function names specifier.
+    case 'f': { // Function names specifier.
       bool FunctionFound = any_of(Values, [&](StringRef Alias) {
         auto It = FunctionNameToDIFilename.find(Alias);
         // No match if this function name is not found in this module.
@@ -129,7 +129,7 @@ Error BasicBlockSectionsProfileReader::ReadV1Profile() {
       DIFilename = "";
       continue;
     }
-    case 'c':  // Basic block cluster specifier.
+    case 'c': // Basic block cluster specifier.
       // Skip the profile when we the profile iterator (FI) refers to the
       // past-the-end element.
       if (FI == ProgramBBClusterInfo.end())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants