-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Re-order some blocks in runtimelookup #83453
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8894243
Re-order some blocks in runtimelookup
EgorBo 65a2e0b
Update runtimelookup.cpp
EgorBo 05293dc
Update runtimelookup.cpp
EgorBo 61b02a5
Merge branch 'main' of github.com:dotnet/runtime into runtimelookup-r…
EgorBo 4f2b996
Merge branch 'main' of github.com:dotnet/runtime into runtimelookup-r…
EgorBo 9311a11
mark blocks cold
EgorBo 73b458b
Restore fgReorderBlocks
EgorBo 2505631
actually we don't need them, let's rely on OptimizeLayout phase
EgorBo 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
Next
Next commit
Re-order some blocks in runtimelookup
- Loading branch information
commit 889424325931da53d84710adae699ab7cb371c90
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 |
|---|---|---|
|
|
@@ -239,12 +239,12 @@ PhaseStatus Compiler::fgExpandRuntimeLookups() | |
| // if (*fastPathValue == null) | ||
| // goto fallbackBb; | ||
| // | ||
| // fastPathBb(BBJ_ALWAYS): [weight: 0.8] | ||
| // rtLookupLcl = *fastPathValue; | ||
| // fallbackBb(BBJ_ALWAYS): [weight: 0.2] | ||
| // rtLookupLcl = HelperCall(); | ||
| // goto block; | ||
| // | ||
| // fallbackBb(BBJ_NONE): [weight: 0.2] | ||
| // rtLookupLcl = HelperCall(); | ||
| // fastPathBb(BBJ_NONE): [weight: 0.8] | ||
| // rtLookupLcl = *fastPathValue; | ||
| // | ||
| // block(...): [weight: 1.0] | ||
| // use(rtLookupLcl); | ||
|
|
@@ -262,15 +262,14 @@ PhaseStatus Compiler::fgExpandRuntimeLookups() | |
| CreateBlockFromTree(this, prevBb, BBJ_COND, gtNewOperNode(GT_JTRUE, TYP_VOID, nullcheckOp), | ||
| debugInfo); | ||
|
|
||
| // Fast-path basic block | ||
| GenTree* asgFastpathValue = gtNewAssignNode(gtClone(rtLookupLcl), fastPathValueClone); | ||
| BasicBlock* fastPathBb = CreateBlockFromTree(this, nullcheckBb, BBJ_NONE, asgFastpathValue, debugInfo); | ||
|
|
||
| // Fallback basic block | ||
| GenTree* asgFallbackValue = gtNewAssignNode(gtClone(rtLookupLcl), call); | ||
| BasicBlock* fallbackBb = | ||
| CreateBlockFromTree(this, nullcheckBb, BBJ_NONE, asgFallbackValue, debugInfo, true); | ||
|
|
||
| // Fast-path basic block | ||
| GenTree* asgFastpathValue = gtNewAssignNode(gtClone(rtLookupLcl), fastPathValueClone); | ||
| BasicBlock* fastPathBb = | ||
| CreateBlockFromTree(this, nullcheckBb, BBJ_ALWAYS, asgFastpathValue, debugInfo); | ||
| CreateBlockFromTree(this, nullcheckBb, BBJ_ALWAYS, asgFallbackValue, debugInfo, true); | ||
|
|
||
| BasicBlock* sizeCheckBb = nullptr; | ||
| if (needsSizeCheck) | ||
|
|
@@ -288,12 +287,12 @@ PhaseStatus Compiler::fgExpandRuntimeLookups() | |
| // if (*fastPathValue == null) | ||
| // goto fallbackBb; | ||
| // | ||
| // fastPathBb(BBJ_ALWAYS): [weight: 0.64] | ||
| // rtLookupLcl = *fastPathValue; | ||
| // fallbackBb(BBJ_ALWAYS): [weight: 0.36] | ||
| // rtLookupLcl = HelperCall(); | ||
| // goto block; | ||
| // | ||
| // fallbackBb(BBJ_NONE): [weight: 0.36] | ||
| // rtLookupLcl = HelperCall(); | ||
| // fastPathBb(BBJ_NONE): [weight: 0.64] | ||
| // rtLookupLcl = *fastPathValue; | ||
| // | ||
| // block(...): [weight: 1.0] | ||
| // use(rtLookupLcl); | ||
|
|
@@ -322,8 +321,8 @@ PhaseStatus Compiler::fgExpandRuntimeLookups() | |
| fgRemoveRefPred(block, prevBb); | ||
| fgAddRefPred(block, fastPathBb); | ||
| fgAddRefPred(block, fallbackBb); | ||
| nullcheckBb->bbJumpDest = fallbackBb; | ||
| fastPathBb->bbJumpDest = block; | ||
| nullcheckBb->bbJumpDest = fastPathBb; | ||
| fallbackBb->bbJumpDest = block; | ||
|
|
||
| if (needsSizeCheck) | ||
| { | ||
|
|
@@ -412,13 +411,5 @@ PhaseStatus Compiler::fgExpandRuntimeLookups() | |
| } | ||
| } | ||
|
|
||
| if (result == PhaseStatus::MODIFIED_EVERYTHING) | ||
| { | ||
| if (opts.OptimizationEnabled()) | ||
| { | ||
| fgReorderBlocks(/* useProfileData */ false); | ||
| fgUpdateChangedFlowGraph(FlowGraphUpdates::COMPUTE_BASICS); | ||
| } | ||
| } | ||
|
Comment on lines
-451
to
-458
Member
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. W.r.t. the confusing diffs, maybe try with this change reverted? |
||
| return result; | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
What if you mark
fallBackBb->bbSetRunRarely()? I had to do similar thing to re-arrange in #80297.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.
vs.