-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[StaticDataLayout] Reconcile two sources of variable hotness #155337
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
Draft
mingmingl-llvm
wants to merge
8
commits into
main
Choose a base branch
from
users/mingmingl-llvm/annotator
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
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
…ss from two sources of profile information
mingmingl-llvm
added a commit
that referenced
this pull request
Aug 28, 2025
…to partition data (#151238) f3f2832 introduces the data access profile format as a payload inside [memprof](https://llvm.org/docs/InstrProfileFormat.html#memprof-profile-data), and the MemProfUse pass reads the memprof payload. This change extends the MemProfUse pass to read the data access profiles to annotate global variables' section prefix. 1. If there are samples for a global variable, it's annotated as hot. 2. If a global variable is seen in the profiled binary file but doesn't have access samples, it's annotated as unlikely. Introduce an option `annotate-static-data-prefix` to flag-gate the global-variable annotation path, and make it false by default. #155337 is the (WIP) draft change to "reconcile" two sources of hotness.
llvm-sync bot
pushed a commit
to arm/arm-toolchain
that referenced
this pull request
Aug 28, 2025
…s profiles to partition data (#151238) llvm/llvm-project@f3f2832 introduces the data access profile format as a payload inside [memprof](https://llvm.org/docs/InstrProfileFormat.html#memprof-profile-data), and the MemProfUse pass reads the memprof payload. This change extends the MemProfUse pass to read the data access profiles to annotate global variables' section prefix. 1. If there are samples for a global variable, it's annotated as hot. 2. If a global variable is seen in the profiled binary file but doesn't have access samples, it's annotated as unlikely. Introduce an option `annotate-static-data-prefix` to flag-gate the global-variable annotation path, and make it false by default. llvm/llvm-project#155337 is the (WIP) draft change to "reconcile" two sources of hotness.
You can test this locally with the following command:git-clang-format --diff origin/main HEAD --extensions cpp,h -- llvm/include/llvm/Analysis/StaticDataProfileInfo.h llvm/lib/Analysis/StaticDataProfileInfo.cpp llvm/lib/CodeGen/StaticDataAnnotator.cpp llvm/lib/CodeGen/StaticDataSplitter.cpp llvm/lib/ProfileData/DataAccessProf.cpp llvm/lib/Transforms/Instrumentation/MemProfUse.cpp
View the diff from clang-format here.diff --git a/llvm/lib/CodeGen/StaticDataSplitter.cpp b/llvm/lib/CodeGen/StaticDataSplitter.cpp
index 97aa833cf..8192adb86 100644
--- a/llvm/lib/CodeGen/StaticDataSplitter.cpp
+++ b/llvm/lib/CodeGen/StaticDataSplitter.cpp
@@ -133,7 +133,8 @@ StaticDataSplitter::getConstant(const MachineOperand &Op,
// Skip 'llvm.'-prefixed global variables conservatively because they are
// often handled specially, and skip those not in static data
// sections.
- if (!GV || llvm::IsReservedGlobalVariable(*GV) || !inStaticDataSection(*GV, TM))
+ if (!GV || llvm::IsReservedGlobalVariable(*GV) ||
+ !inStaticDataSection(*GV, TM))
return nullptr;
return GV;
}
|
This was referenced Oct 7, 2025
mingmingl-llvm
added a commit
that referenced
this pull request
Oct 13, 2025
…ta access profiles by module flag. (#162333) The codegen pass in the pipeline can read the module flag to tell whether the IR is compiled with data access profile, to support two use cases when `memprof-annotate-static-data-prefix=true` is enabled 1. The binary is compiled with data access profiles. - The module flag will have value 1, and codegen pass should regard an empty section prefix as 'unknown' and conservatively not placing the data into `.unlikely` data sections. 2. The binary is compiled without data access profiles (e.g., during incremental rollout, etc) - The module flag will have value 0, and codegen pass can override an empty section prefix based on PGO counters. #155337 shows the motivating use case in function `StaticDataProfileInfo::getConstantSectionPrefix` in `llvm/lib/Analysis/StaticDataProfileInfo.cpp` This is the 1st patch as a split of #155337
llvm-sync bot
pushed a commit
to arm/arm-toolchain
that referenced
this pull request
Oct 13, 2025
…led with data access profiles by module flag. (#162333) The codegen pass in the pipeline can read the module flag to tell whether the IR is compiled with data access profile, to support two use cases when `memprof-annotate-static-data-prefix=true` is enabled 1. The binary is compiled with data access profiles. - The module flag will have value 1, and codegen pass should regard an empty section prefix as 'unknown' and conservatively not placing the data into `.unlikely` data sections. 2. The binary is compiled without data access profiles (e.g., during incremental rollout, etc) - The module flag will have value 0, and codegen pass can override an empty section prefix based on PGO counters. llvm/llvm-project#155337 shows the motivating use case in function `StaticDataProfileInfo::getConstantSectionPrefix` in `llvm/lib/Analysis/StaticDataProfileInfo.cpp` This is the 1st patch as a split of llvm/llvm-project#155337
mingmingl-llvm
added a commit
that referenced
this pull request
Oct 13, 2025
…igibility and use it in both optimizer and codegen (#162348) This change introduces new helper functions to check if a global variable is eligible for section prefix annotation. This shared logic is used by both MemProfUse and StaticDataSplitter to avoid annotating ineligible variables. This is the 2nd patch as a split of #155337
llvm-sync bot
pushed a commit
to arm/arm-toolchain
that referenced
this pull request
Oct 13, 2025
…n prefix eligibility and use it in both optimizer and codegen (#162348) This change introduces new helper functions to check if a global variable is eligible for section prefix annotation. This shared logic is used by both MemProfUse and StaticDataSplitter to avoid annotating ineligible variables. This is the 2nd patch as a split of llvm/llvm-project#155337
mingmingl-llvm
added a commit
that referenced
this pull request
Oct 13, 2025
…gen (#162349) The section prefix validation was initially added when global variable's section prefix is only added in the codegen pass. Now the optimizer pass MemProfUse can annotate data section prefix by making use of data access profiles, so we can remove the validation. Also calls `setSectionPrefix` which returns whether section prefix is updated. This is the 3rd patch as a split of #155337
llvm-sync bot
pushed a commit
to arm/arm-toolchain
that referenced
this pull request
Oct 13, 2025
…ion in codegen (#162349) The section prefix validation was initially added when global variable's section prefix is only added in the codegen pass. Now the optimizer pass MemProfUse can annotate data section prefix by making use of data access profiles, so we can remove the validation. Also calls `setSectionPrefix` which returns whether section prefix is updated. This is the 3rd patch as a split of llvm/llvm-project#155337
akadutta
pushed a commit
to akadutta/llvm-project
that referenced
this pull request
Oct 14, 2025
…ta access profiles by module flag. (llvm#162333) The codegen pass in the pipeline can read the module flag to tell whether the IR is compiled with data access profile, to support two use cases when `memprof-annotate-static-data-prefix=true` is enabled 1. The binary is compiled with data access profiles. - The module flag will have value 1, and codegen pass should regard an empty section prefix as 'unknown' and conservatively not placing the data into `.unlikely` data sections. 2. The binary is compiled without data access profiles (e.g., during incremental rollout, etc) - The module flag will have value 0, and codegen pass can override an empty section prefix based on PGO counters. llvm#155337 shows the motivating use case in function `StaticDataProfileInfo::getConstantSectionPrefix` in `llvm/lib/Analysis/StaticDataProfileInfo.cpp` This is the 1st patch as a split of llvm#155337
akadutta
pushed a commit
to akadutta/llvm-project
that referenced
this pull request
Oct 14, 2025
…igibility and use it in both optimizer and codegen (llvm#162348) This change introduces new helper functions to check if a global variable is eligible for section prefix annotation. This shared logic is used by both MemProfUse and StaticDataSplitter to avoid annotating ineligible variables. This is the 2nd patch as a split of llvm#155337
akadutta
pushed a commit
to akadutta/llvm-project
that referenced
this pull request
Oct 14, 2025
…gen (llvm#162349) The section prefix validation was initially added when global variable's section prefix is only added in the codegen pass. Now the optimizer pass MemProfUse can annotate data section prefix by making use of data access profiles, so we can remove the validation. Also calls `setSectionPrefix` which returns whether section prefix is updated. This is the 3rd patch as a split of llvm#155337
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.
TODO: regression test coverage.