-
Notifications
You must be signed in to change notification settings - Fork 5.2k
JIT: Add fgRedirectTrueEdge, fgRedirectFalseEdge #99561
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
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -449,6 +449,118 @@ void Compiler::fgRedirectTargetEdge(BasicBlock* block, BasicBlock* newTarget) | |
| newTarget->bbRefs++; | ||
| } | ||
|
|
||
| //------------------------------------------------------------------------ | ||
| // fgRedirectTrueEdge: Sets block->bbTrueEdge's target block to newTarget, | ||
| // updating pred lists as necessary. | ||
| // | ||
| // Arguments: | ||
| // block -- The block we want to make a predecessor of newTarget. | ||
| // It could be one already, in which case nothing changes. | ||
| // newTarget -- The new successor of block. | ||
| // | ||
| // Notes: | ||
| // This assumes block's true and false targets are different. | ||
| // If setting block's true target to its false target, | ||
| // fgRedirectTrueEdge increments the false edge's dup count, | ||
| // and ensures block->bbTrueEdge == block->bbFalseEdge. | ||
| // We don't update newTarget->bbPreds in this case, | ||
| // as we don't want to have more than one edge from the same predecessor. | ||
| // | ||
| void Compiler::fgRedirectTrueEdge(BasicBlock* block, BasicBlock* newTarget) | ||
| { | ||
| assert(block != nullptr); | ||
| assert(newTarget != nullptr); | ||
| assert(block->KindIs(BBJ_COND)); | ||
| assert(!block->TrueEdgeIs(block->GetFalseEdge())); | ||
|
|
||
| // Update oldTarget's pred list. | ||
| // We could call fgRemoveRefPred, but since we're removing the one and only ref from block to oldTarget, | ||
| // fgRemoveAllRefPreds is slightly more efficient (one fewer branch, doesn't update edge's dup count, etc). | ||
| // | ||
| FlowEdge* trueEdge = block->GetTrueEdge(); | ||
| BasicBlock* oldTarget = trueEdge->getDestinationBlock(); | ||
| fgRemoveAllRefPreds(oldTarget, block); | ||
|
|
||
| // Splice edge into new target block's pred list | ||
| // | ||
| FlowEdge** predListPtr = fgGetPredInsertPoint(block, newTarget); | ||
| FlowEdge* predEdge = *predListPtr; | ||
|
|
||
| if (block->FalseEdgeIs(predEdge)) | ||
| { | ||
| block->SetTrueEdge(predEdge); | ||
| predEdge->incrementDupCount(); | ||
| } | ||
| else | ||
| { | ||
| trueEdge->setNextPredEdge(predEdge); | ||
| trueEdge->setDestinationBlock(newTarget); | ||
| *predListPtr = trueEdge; | ||
| } | ||
|
|
||
| newTarget->bbRefs++; | ||
|
|
||
| // Pred list of target should (still) be ordered | ||
| // | ||
| assert(newTarget->checkPredListOrder()); | ||
| } | ||
|
|
||
| //------------------------------------------------------------------------ | ||
| // fgRedirectFalseEdge: Sets block->bbFalseEdge's target block to newTarget, | ||
| // updating pred lists as necessary. | ||
| // | ||
| // Arguments: | ||
| // block -- The block we want to make a predecessor of newTarget. | ||
| // It could be one already, in which case nothing changes. | ||
| // newTarget -- The new successor of block. | ||
| // | ||
| // Notes: | ||
| // This assumes block's true and false targets are different. | ||
| // If setting block's false target to its true target, | ||
| // fgRedirectFalseEdge increments the true edge's dup count, | ||
| // and ensures block->bbTrueEdge == block->bbFalseEdge. | ||
| // We don't update newTarget->bbPreds in this case, | ||
| // as we don't want to have more than one edge from the same predecessor. | ||
| // | ||
| void Compiler::fgRedirectFalseEdge(BasicBlock* block, BasicBlock* newTarget) | ||
|
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. Please add a header comment block for this method |
||
| { | ||
| assert(block != nullptr); | ||
| assert(newTarget != nullptr); | ||
| assert(block->KindIs(BBJ_COND)); | ||
| assert(!block->TrueEdgeIs(block->GetFalseEdge())); | ||
|
|
||
| // Update oldTarget's pred list. | ||
| // We could call fgRemoveRefPred, but since we're removing the one and only ref from block to oldTarget, | ||
| // fgRemoveAllRefPreds is slightly more efficient (one fewer branch, doesn't update edge's dup count, etc). | ||
| // | ||
| FlowEdge* falseEdge = block->GetFalseEdge(); | ||
| BasicBlock* oldTarget = falseEdge->getDestinationBlock(); | ||
| fgRemoveAllRefPreds(oldTarget, block); | ||
|
|
||
| // Splice edge into new target block's pred list | ||
| // | ||
| FlowEdge** predListPtr = fgGetPredInsertPoint(block, newTarget); | ||
| FlowEdge* predEdge = *predListPtr; | ||
|
|
||
| if (block->TrueEdgeIs(predEdge)) | ||
| { | ||
| block->SetFalseEdge(predEdge); | ||
| predEdge->incrementDupCount(); | ||
| } | ||
| else | ||
| { | ||
| falseEdge->setNextPredEdge(predEdge); | ||
| falseEdge->setDestinationBlock(newTarget); | ||
| *predListPtr = falseEdge; | ||
| } | ||
|
|
||
| newTarget->bbRefs++; | ||
|
|
||
| // Pred list of target should (still) be ordered | ||
| // | ||
| assert(newTarget->checkPredListOrder()); | ||
| } | ||
|
|
||
| Compiler::SwitchUniqueSuccSet Compiler::GetDescriptorForSwitch(BasicBlock* switchBlk) | ||
| { | ||
| assert(switchBlk->KindIs(BBJ_SWITCH)); | ||
|
|
||
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.
Please add a header comment block for this method