-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[Inline][PGO] After inline, update InvokeInst profile counts in caller and cloned callee #83809
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
Changes from all commits
e7c6220
919f9a2
0f18694
9575b83
03ea516
15776ef
8555e5a
a8aef1b
572ac63
783c30d
fa02c56
b5725c4
ffd4581
b1c57f6
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 |
---|---|---|
|
@@ -46,6 +46,9 @@ constexpr unsigned WeightsIdx = 1; | |
// the minimum number of operands for MD_prof nodes with branch weights | ||
constexpr unsigned MinBWOps = 3; | ||
|
||
// the minimum number of operands for MD_prof nodes with value profiles | ||
constexpr unsigned MinVPOps = 5; | ||
|
||
// We may want to add support for other MD_prof types, so provide an abstraction | ||
// for checking the metadata type. | ||
bool isTargetMD(const MDNode *ProfData, const char *Name, unsigned MinOps) { | ||
|
@@ -97,11 +100,25 @@ bool isBranchWeightMD(const MDNode *ProfileData) { | |
return isTargetMD(ProfileData, "branch_weights", MinBWOps); | ||
} | ||
|
||
bool isValueProfileMD(const MDNode *ProfileData) { | ||
return isTargetMD(ProfileData, "VP", MinVPOps); | ||
} | ||
|
||
bool hasBranchWeightMD(const Instruction &I) { | ||
auto *ProfileData = I.getMetadata(LLVMContext::MD_prof); | ||
return isBranchWeightMD(ProfileData); | ||
} | ||
|
||
bool hasCountTypeMD(const Instruction &I) { | ||
auto *ProfileData = I.getMetadata(LLVMContext::MD_prof); | ||
// Value profiles record count-type information. | ||
if (isValueProfileMD(ProfileData)) | ||
return true; | ||
// Conservatively assume non CallBase instruction only get taken/not-taken | ||
// branch probability, so not interpret them as count. | ||
return isa<CallBase>(I) && !isBranchWeightMD(ProfileData); | ||
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. It seems that the check of CallBase is not necessary. Select instruction is another one taking prof MD, and it can only be branch weight type. If checking callbase is not needed, passing Profile meta data pointer is better. 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. Non-CallBase instructions (e.g., SwitchInst) could have branch weights with two ops (i.e., one 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. Right, I forgot about SwitchInst with only default case. (Note that the documentation is out of date. SelectInst also supports branch_weights). LGTM. |
||
} | ||
|
||
bool hasValidBranchWeightMD(const Instruction &I) { | ||
return getValidBranchWeightMDNode(I); | ||
} | ||
|
@@ -212,6 +229,9 @@ void scaleProfData(Instruction &I, uint64_t S, uint64_t T) { | |
ProfDataName->getString() != "VP")) | ||
return; | ||
|
||
if (!hasCountTypeMD(I)) | ||
return; | ||
|
||
LLVMContext &C = I.getContext(); | ||
|
||
MDBuilder MDB(C); | ||
|
Uh oh!
There was an error while loading. Please reload this page.