-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
JIT: Assert bbJumpKind in BasicBlock::HasJump #95152
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
71c3b2b
Assert bbJumpKind in BasicBlock::HasJump
amanasifkhalid 68e982b
Rename to HasInitializedJumpDest
amanasifkhalid 776b0e3
Fix merge conflict
amanasifkhalid ff9faad
Add HasJumpDest()
amanasifkhalid 11c3366
Fix HasJumpDest
amanasifkhalid e037c3a
Fix merge conflict
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 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 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 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 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 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 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 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 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 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
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.
What is the point of
HasJump()
? It seems like a check for whether the block is in some half-constructed state, since I would expect the block kinds above always to have validbbJumpDest
. It does not really make sense for me to have this function with the assert that is added here.An assert that would make more sense to me would be:
or
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.
Ah, I see that @BruceForstall's feedback in #94239 was about this being a union field.
I would like to understand when it is expected that these jump kinds have a null
bbJumpDest
. Maybe that happens only for a very short while when we're initializing the flow graph? In that case, consider renaming this function toHasInitializedJumpDest()
or something of the sort, to make that clear. I think it is a bit confusing currently, as it makes it seem like an expected situation that some of these blocks do not have a validbbJumpDest
, which should not be possible.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.
Yes, there are a few cases where we have to create a block that requires a jump target without knowing the target yet. For example, in
Compiler::fgMakeBasicBlocks
, we create blocks only knowing the offset of their jump targets, and set the actual target block later inCompiler::fgLinkBasicBlocks
. The tougher cases are during importing, where we sometimes create aBBJ_ALWAYS
orBBJ_CALLFINALLY
without setting its jump target in a loop, and then create and set the jump target in a later iteration of the loop. There are a few other spots where we do this pattern, but I can't remember off the top of my head...Your first suggested assert seems to best communicate what
HasJump
should do; for block kinds that should never readbbJumpDest
,bbJumpDest
should not be set, elsebbJumpDest
must be set (i.e. we shouldn't be in some half-constructed state) before performing any conditional logic based on whether the block has a jump or not.Edit: Ah nevermind, I realize we check for this uninitialized block jump state in
Compiler::impImportLeave
in a few places, and I'd rather not touch the importer code in this PR to better fit the asserts inHasJump
. Right now, we seem to only checkHasJump
for blocks that should have a jump target (eventually), so maybe renaming it to something likeHasInitializedJumpDest
makes more sense.