[release/10.0] Fix bug in LowerCallMemmove#125173
Closed
Conversation
Contributor
|
Tagging subscribers to this area: @dotnet/runtime-infrastructure |
Co-authored-by: EgorBo <523221+EgorBo@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Backport fix from PR 123907 into release 10.0 branch
[release/10.0] Fix bug in LowerCallMemmove
Mar 4, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
main PR #123907
Description
LowerCallMemmovehandledCORINFO_HELP_MEMCPYby settingBlkOpKindUnrollon the newly constructedSTORE_BLK, but then skipped re-loweringsrcBlk/storeBlkentirely. This left the address nodes in an unlowered state, allowing them to become contained — violating the contract thatgenCodeForMemmove(andgenCodeForCpBlkUnroll) rely on.Fix: always use
BlkOpKindUnrollMemmovefor both memmove and memcpy paths. The nodes are hand-constructed already in their final lowered form, sogenCodeForMemmovehandles them correctly without a separate lowering pass.assert(!dstAddr->isContained())/assert(!srcAddr->isContained())— enforces the invariantgenCodeForMemmoverelies on, and catches future regressions.BlkOpKindUnroll— useBlkOpKindUnrollMemmoveunconditionally; avoids the need to re-lower nodes created by this function.// TODO: This skips lowering srcBlk and storeBlk.with an accurate explanation.Customer Impact
Unsafe.CopyBlockUnaligned/cpblkwith a size that becomes constant in a late JIT phase can produce incorrect code on affected builds.Regression
Present since
CORINFO_HELP_MEMCPYhandling was added toLowerCallMemmove.Testing
Covered by the existing memmove/memcpy unrolling test suite. The original fix in
mainwas validated with no jit-diffs (see PR #123907).Risk
Low. Single-function change, logic simplification only — removes a conditional branch and adds debug-only assertions. The
CORINFO_HELP_MEMCPYunroll path is rarely exercised (requires constant-lengthcpblkresolved in a late phase).BlkOpKindUnrollMemmoveis already the well-tested code path for the memmove case.Package authoring no longer needed in .NET 9
IMPORTANT: Starting with .NET 9, you no longer need to edit a NuGet package's csproj to enable building and bump the version.
Keep in mind that we still need package authoring in .NET 8 and older versions.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.