Repository navigation
Conversation
GTF_CALL_HOISTABLE on a static base helper means the class is beforefieldinit, so the class constructor may run earlier and the call can be hoisted. Value numbering and the loop memory summary also used the flag to treat the call as not modifying the heap. The cctor still modifies the heap when the call runs it, so a static read after the access could reuse a value read before the cctor ran, and a static read in a loop could be hoisted above the first iteration's cctor. Always treat a helper that may run a cctor as a heap write in value numbering and the loop memory summary. Loop hoisting still uses the flag to hoist the call itself. Fixes dotnet#136042 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 54a50cd7-49f7-4a8f-b719-8ac44ccc806a
Fold the cctor heap effect into the modHeap initialization in fgValueNumberHelperCall and shorten the related comments. Give each static class in Runtime_136042 its own counter so the expected values do not depend on the order in which the class constructors run. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 54a50cd7-49f7-4a8f-b719-8ac44ccc806a
|
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. |
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
This was referenced Oct 20, 2026
This branch has not been deployed
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.
For
beforefieldinitclasses, static base helper calls carryGTF_CALL_HOISTABLE. Loop hoisting reads it as "may run the cctor early", which is legal. Value numbering and the loop memory summary also read it as "doesn't modify the heap", which is wrong when the call runs the cctor, so a static read after the access can reuse a value loaded before the cctor ran:Every helper that may run a cctor now counts as a heap write in VN and the loop summary; the flag keeps only its hoisting meaning. The cost is small FullOpts regressions, at most 0.01% of any collection.
Resolves #136042
SuperPMI: diffs
Local SuperPMI breakdown and typical regressions
LowLevelPerf:GenericClassGenericStaticFieldreloads the loop bound).Lock:Exitreloads a field afterREADYTORUN_THREADSTATIC_BASE).A less conservative model (tracking classes already initialized on dominating paths) is possible but not needed for correctness.
Note
This PR description was drafted with GitHub Copilot.