JIT: don't let tail-merge try and remove the OSR-protected entry block#131164
JIT: don't let tail-merge try and remove the OSR-protected entry block#131164AndyAyersMS wants to merge 1 commit into
Conversation
Fixes dotnet#131056 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@jakobbotsch PTAL |
|
Azure Pipelines: Successfully started running 5 pipeline(s). 11 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
There was a problem hiding this comment.
Pull request overview
This PR prevents fgHeadTailMerge from removing the OSR-protected original entry block (fgEntryBB) while it still has an artificial bbRefs increment applied during import. This avoids hitting fgRemoveBlock assertions that require removed blocks to have bbRefs == 0 and bbPreds == nullptr.
Changes:
- Add an OSR-specific guard in tail-merge block removal to skip removing
fgEntryBBwhile it is still tracked as the “original method entry”. - Add an explanatory comment documenting the OSR artificial
bbRefsbump / unprotect sequence.
|
Thank you for the fix. |
|
Rerunning failed build. |
| // Try to remove emptyBlock and make its preds jump directly to newTarget. | ||
| // Under OSR, the original method entry (fgEntryBB) has an artificial bbRefs | ||
| // bump to keep it live until morph un-protects it; removing it here would | ||
| // leave that ref dangling and trip asserts in fgRemoveBlock. | ||
| // | ||
| bool canRemove = | ||
| !emptyBlock->HasFlag(BBF_DONT_REMOVE) && (emptyBlock != fgFirstBB) && (emptyBlock != fgOSREntryBB); | ||
| bool canRemove = !emptyBlock->HasFlag(BBF_DONT_REMOVE) && (emptyBlock != fgFirstBB) && | ||
| (emptyBlock != fgOSREntryBB) && (!opts.IsOSR() || (emptyBlock != fgEntryBB)); |
There was a problem hiding this comment.
It's a nit, but I assume this could just be emptyBlock != fgEntryBB, isn't fgEntryBB always null outside OSR?
jakobbotsch
left a comment
There was a problem hiding this comment.
LGTM, feel free to ignore
Fixes #131056