-
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
Changes from 3 commits
73d6985
85dccaf
a2ec8c4
36b85b8
523ee22
c6fdc19
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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,18 @@ 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); | ||
// FuncPGOInstrumentation ctor finds value sites for each kind. It runs on the | ||
// common path of pgo-instr-gen and pgo-instr-use, and vtable kind path | ||
// is gated by `-enable-vtable-value-profiling`. If vtable profiles are | ||
// present, not explicitly discarded and vtable sites remain empty, try to | ||
// find the sites again. | ||
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. |
||
FuncInfo.ValueSites[Kind].empty() && | ||
!(EnableVTableProfileUse.getNumOccurrences() && | ||
EnableVTableProfileUse == false)) | ||
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. Why does this need to depend on whether we are using it in the optimization passes? Won't we then get matching warnings if someone disables that? 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.
While adding TODOs to speed up optimized build by skipping |
||
FuncInfo.ValueSites[IPVK_VTableTarget] = VPC.get(IPVK_VTableTarget); | ||
auto &ValueSites = FuncInfo.ValueSites[Kind]; | ||
if (NumValueSites != ValueSites.size()) { | ||
auto &Ctx = M->getContext(); | ||
Ctx.diagnose(DiagnosticInfoPGOProfile( | ||
|
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.
Why can't this just always be done here:
llvm-project/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
Lines 606 to 607 in d06b55e
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.
This runs on the common path of
pgo-instr-gen
andpgo-instr-run
. There isn't a reliably way to tell if iFDO profile are generated with--enable-vtable-value-profiling
or not [1], and it's preferred to have an option to disableVPC.get(IPVK_VTableTarget)
(which iterates instructions and collect instrumentation sites via InstVisitor)As discussed, I simplified this code by
VPC.get(IPVK_VTableTarget)
[1] if a program doesn't use vtable but its instrumented profiles are generated with
--enable-vtable-value-profiling=true
, iterating function profile record won't tell this with the current profile format.