-
Notifications
You must be signed in to change notification settings - Fork 5.2k
JIT: Propagate flow into finally regions correctly in synthesis #114016
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
amanasifkhalid
merged 9 commits into
dotnet:main
from
amanasifkhalid:fix-profile-synthesis
Apr 3, 2025
Merged
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3e5a6d0
Check BBJ_CALLFINALLYRET weight correctly
amanasifkhalid 1816412
Propagate flow into finally regions correctly
amanasifkhalid 50abab8
Allocate cyclic probabilities array once
amanasifkhalid 4dfddff
Compute finally successor edge likelihoods using entry weights
amanasifkhalid 5a39850
Feedback
amanasifkhalid e3f4462
Enable likelihood checks for BBJ_EHFINALLYRET blocks
amanasifkhalid 66be069
Enable post-synthesis consistency checking
amanasifkhalid b419dfd
Handle removing dominant successor edge
amanasifkhalid 25dec79
Feedback
amanasifkhalid 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -368,6 +368,16 @@ void Compiler::fgRemoveEhfSuccessor(BasicBlock* block, const unsigned succIndex) | |
| (succCount - succIndex - 1) * sizeof(FlowEdge*)); | ||
| } | ||
|
|
||
| // If the block has other successors, distribute the removed edge's likelihood among the remaining successor edges. | ||
| if (succCount > 1) | ||
| { | ||
| const weight_t likelihoodIncrease = succEdge->getLikelihood() / (succCount - 1); | ||
| for (unsigned i = 0; i < (succCount - 1); i++) | ||
| { | ||
| succTab[i]->addLikelihood(likelihoodIncrease); | ||
| } | ||
| } | ||
|
|
||
| #ifdef DEBUG | ||
| // We only expect to see a successor once in the table. | ||
| for (unsigned i = succIndex; i < (succCount - 1); i++) | ||
|
|
@@ -427,6 +437,16 @@ void Compiler::fgRemoveEhfSuccessor(FlowEdge* succEdge) | |
| } | ||
| } | ||
|
|
||
| // If the block has other successors, distribute the removed edge's likelihood among the remaining successor edges. | ||
| if (succCount > 1) | ||
|
||
| { | ||
| const weight_t likelihoodIncrease = succEdge->getLikelihood() / (succCount - 1); | ||
| for (unsigned i = 0; i < (succCount - 1); i++) | ||
| { | ||
| succTab[i]->addLikelihood(likelihoodIncrease); | ||
| } | ||
| } | ||
|
|
||
| assert(found); | ||
| ehfDesc->bbeCount--; | ||
| } | ||
|
|
||
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.
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.
Shouldn't these proportionally scale up?
Say there are 3 successors with likelihoods A 0.1, B 0.1, C 0.8. We remove A. Then we should have B = 0.1111..., C = 0.8888...
With these changes we'd get B = 0.15, C = 0.85, so the relative likelihood of B would increase.
Generally$p_{i,new} = p_{i,old} / (1 - p_{removed})$ , unless $p_{removed}$ is 1.0 or close to 1.0, in which case equal distribution seems ok.
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.
Good point; fixed