This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Streamline fgExcludeFromSsa#15351
Merged
Merged
Conversation
a9768e5 to
297bab5
Compare
briansull
reviewed
Apr 13, 2018
briansull
left a comment
There was a problem hiding this comment.
Looks Good, we should get AsmDiffs
Author
|
I ran jit-diff fx+tests on x86/64 - no diffs. Updated PR title to match commit. This started initially being solely about excluding some variables from SSA but then it turned out that it was slightly slower due to the extra |
|
Nice change, thank you. |
This function is relatively expensive due to the many checks it does. Adding an LclVarDsc "in SSA" bit that is set during SSA construction by calling fgExcludeFromSsa only once per variable results in 0.35% drop in instructions retired. Most of the checks done in fgExcludeFromSsa are implied by lvTracked and they could probably be converted to asserts. But lvOverlappingFields is not implied by lvTracked so even if all redundant checks are converted to asserts fgExcludeFromSsa still needs 2 checks rather than just one. Incidentally, this difference between tracked variables and SSA variables results in SSA and value numbers being assigned to some variables that are actually excluded from SSA - SsaBuilder::RenameVariables and fgValueNumber assign numbers to all live in fgFirstBB variables that require initialization without checking fgExcludeFromSsa first. Structs with overlapping fields are not common but properly excluding them is still enough to save 0.15% memory when compiling corelib. - Replace calls to fgExcludeFromSsa with calls to lvaInSsa (the old name is kind of weird, it has nothing to do with the flow graph and "exclude" results in double negation) - Move fgExcludeFromSsa logic to SsaBuild::IncludeInSsa and use it to initialize LclVarDsc::lvInSsa for all variables - Change RenameVariables and fgValueNumber to call lvaInSsa before assigning numbers to live in fgFirstBB variables
Author
|
@sandreenko Conflicts fixed, thank you |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
This function is relatively expensive due to the many checks it does. Adding an
LclVarDsc"in SSA" bit that is set during SSA construction by callingfgExcludeFromSsaonly once per variable results in 0.35% drop in instructions retired.Most of the checks done in
fgExcludeFromSsaare implied bylvTrackedand they could probably be converted to asserts. ButlvOverlappingFieldsis not implied bylvTrackedso even if all redundant checks are converted to assertsfgExcludeFromSsastill needs 2 checks rather than just one.Incidentally, this difference between tracked variables and SSA variables results in SSA and value numbers being assigned to some variables that are actually excluded from SSA -
SsaBuilder::RenameVariablesandfgValueNumberassign numbers to all live infgFirstBBvariables that require initialization without checkingfgExcludeFromSsafirst. Structs with overlapping fields are not common but properly excluding them is still enough to save 0.15% memory when compiling corelib.fgExcludeFromSsawith calls tolvaInSsa(the old name is kind of weird, it has nothing to do with the flow graph and "exclude" results in double negation)fgExcludeFromSsalogic toSsaBuild::IncludeInSsaand use it to initializeLclVarDsc::lvInSsafor all variablesRenameVariablesandfgValueNumberto calllvaInSsabefore assigning numbers to live infgFirstBBvariablesPIN data: https://1drv.ms/x/s!Av4baJYSo5pjgrsOjE-3c5Tow10lFw
MemStats diff: https://gist.github.com/mikedn/9c9d6d7b40306d9fff18109c3a4b5e9c