-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[llvm][IR] Extend BranchWeightMetadata to track provenance of weights #86609
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
Merged
ilovepi
merged 18 commits into
main
from
users/ilovepi/spr/llvmir-extend-branchweightmetadata-to-track-provenance-of-weights
Jun 10, 2024
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
1e9dbac
[𝘀𝗽𝗿] changes to main this commit is based on
ilovepi ffb5bb8
[𝘀𝗽𝗿] initial version
ilovepi ee503bf
[𝘀𝗽𝗿] changes introduced through rebase
ilovepi 7217003
git clang-format
ilovepi 7b541e1
[𝘀𝗽𝗿] changes introduced through rebase
ilovepi e5bd278
Address comments
ilovepi af27efe
[𝘀𝗽𝗿] changes introduced through rebase
ilovepi bc338aa
rebase
ilovepi 5a5ae01
[𝘀𝗽𝗿] changes introduced through rebase
cor3ntin 6e16264
Rebase
ilovepi 56c4658
[𝘀𝗽𝗿] changes introduced through rebase
wzssyqa 319aaa6
Fix mismerge and rebase on main
ilovepi 37af7e2
[𝘀𝗽𝗿] changes introduced through rebase
coderchenlin 21382a0
Avoid unrelated refactoring and rebase
ilovepi 6729b47
[𝘀𝗽𝗿] changes introduced through rebase
erichkeane 4749bdc
Rebase
ilovepi 7760282
Add assert for metadata string value
ilovepi 947f9e1
Rename hasBranchWeightProvenance to hasBranchWeightOrigin
ilovepi 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 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
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
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,6 +104,7 @@ | |
#include "llvm/IR/Module.h" | ||
#include "llvm/IR/ModuleSlotTracker.h" | ||
#include "llvm/IR/PassManager.h" | ||
#include "llvm/IR/ProfDataUtils.h" | ||
#include "llvm/IR/Statepoint.h" | ||
#include "llvm/IR/Type.h" | ||
#include "llvm/IR/Use.h" | ||
|
@@ -4808,8 +4809,10 @@ void Verifier::visitProfMetadata(Instruction &I, MDNode *MD) { | |
|
||
// Check consistency of !prof branch_weights metadata. | ||
if (ProfName == "branch_weights") { | ||
unsigned int Offset = getBranchWeightOffset(MD); | ||
if (isa<InvokeInst>(&I)) { | ||
Check(MD->getNumOperands() == 2 || MD->getNumOperands() == 3, | ||
Check(MD->getNumOperands() == (1 + Offset) || | ||
MD->getNumOperands() == (2 + Offset), | ||
Comment on lines
+4814
to
+4815
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. More opportunities for a possible |
||
"Wrong number of InvokeInst branch_weights operands", MD); | ||
} else { | ||
unsigned ExpectedNumOperands = 0; | ||
|
@@ -4829,10 +4832,10 @@ void Verifier::visitProfMetadata(Instruction &I, MDNode *MD) { | |
CheckFailed("!prof branch_weights are not allowed for this instruction", | ||
MD); | ||
|
||
Check(MD->getNumOperands() == 1 + ExpectedNumOperands, | ||
Check(MD->getNumOperands() == Offset + ExpectedNumOperands, | ||
"Wrong number of operands", MD); | ||
} | ||
for (unsigned i = 1; i < MD->getNumOperands(); ++i) { | ||
for (unsigned i = Offset; i < MD->getNumOperands(); ++i) { | ||
auto &MDO = MD->getOperand(i); | ||
Check(MDO, "second operand should not be null", MD); | ||
Check(mdconst::dyn_extract<ConstantInt>(MDO), | ||
|
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
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
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
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
Oops, something went wrong.
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.
This seems simple enough to do something about it instead of adding a
FIXME
? Could for example add agetNumBranchWeights(<profile_data>)
API so this can becomegetNumBranchWeights(ProfileData) != SI.getNumSuccessors()
?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.
Another good suggestion. Thank you.