-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
[InstrPGO][TypeProf]Annotate vtable types when they are present in the profile #99402
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
73d6985
[InstrPGO][TypeProf]Annotate vtable types if they are present in the …
minglotus-6 85dccaf
fix line number
minglotus-6 a2ec8c4
wrap RUN lines and update remark line number accordingly
minglotus-6 36b85b8
resolve review feedback
minglotus-6 523ee22
compute the instrumented vtable sites from function IR if function pr…
minglotus-6 c6fdc19
resolve review feedback
minglotus-6 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1096,7 +1096,7 @@ class PGOUseFunc { | |
: F(Func), M(Modu), BFI(BFIin), PSI(PSI), | ||
FuncInfo(Func, TLI, ComdatMembers, false, BPI, BFIin, IsCS, | ||
InstrumentFuncEntry, HasSingleByteCoverage), | ||
FreqAttr(FFA_Normal), IsCS(IsCS) {} | ||
FreqAttr(FFA_Normal), IsCS(IsCS), VPC(Func, TLI) {} | ||
|
||
void handleInstrProfError(Error Err, uint64_t MismatchedFuncSum); | ||
|
||
|
@@ -1178,6 +1178,8 @@ class PGOUseFunc { | |
// Is to use the context sensitive profile. | ||
bool IsCS; | ||
|
||
ValueProfileCollector VPC; | ||
|
||
// Find the Instrumented BB and set the value. Return false on error. | ||
bool setInstrumentedCounts(const std::vector<uint64_t> &CountFromProfile); | ||
|
||
|
@@ -1755,8 +1757,22 @@ void PGOUseFunc::annotateValueSites() { | |
void PGOUseFunc::annotateValueSites(uint32_t Kind) { | ||
assert(Kind <= IPVK_Last); | ||
unsigned ValueSiteIndex = 0; | ||
auto &ValueSites = FuncInfo.ValueSites[Kind]; | ||
|
||
unsigned NumValueSites = ProfileRecord.getNumValueSites(Kind); | ||
|
||
// Since there isn't a reliable or fast way for profile reader to tell if a | ||
// profile is generated with `-enable-vtable-value-profiling` on, we run the | ||
// value profile collector over the function IR to find the instrumented sites | ||
// iff function profile records shows the number of instrumented vtable sites | ||
// is not zero. Function cfg already takes the number of instrumented | ||
// indirect call sites into account so it doesn't hash the number of | ||
// instrumented vtables; as a side effect it makes it easier to enable | ||
// profiling and profile use in two steps if needed. | ||
if (NumValueSites > 0 && Kind == IPVK_VTableTarget && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add a TODO to remove this if/when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done. |
||
NumValueSites != FuncInfo.ValueSites[IPVK_VTableTarget].size() && | ||
MaxNumVTableAnnotations != 0) | ||
FuncInfo.ValueSites[IPVK_VTableTarget] = VPC.get(IPVK_VTableTarget); | ||
auto &ValueSites = FuncInfo.ValueSites[Kind]; | ||
if (NumValueSites != ValueSites.size()) { | ||
auto &Ctx = M->getContext(); | ||
Ctx.diagnose(DiagnosticInfoPGOProfile( | ||
|
Oops, something went wrong.
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.
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.
typo in. "annotaitons". However, this isn't the option used in the test below? It does seem to be what is used in the source code, however.
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.
The option name is wrong. I corrected it.
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.
I'm confused though because the code in the PR checks MaxNumVTableAnnotations.
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.
ah this is because the option variable name is
MaxNumVTableAnnotations
but its registered string isicp-max-num-vtables
.llvm-project/llvm/lib/Analysis/IndirectCallPromotionAnalysis.cpp
Lines 48 to 50 in bee2654
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.
Oh, I see. I was thrown off by the naming difference.