Skip to content
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

SpillSequenceSpiller.Spill - ensure sequences under ref assignments are spilled. #58657

Merged
merged 2 commits into from
Jan 10, 2022

Conversation

AlekseyTs
Copy link
Contributor

Fixes #58569.

@AlekseyTs AlekseyTs requested a review from a team as a code owner January 6, 2022 01:03
@333fred
Copy link
Member

333fred commented Jan 6, 2022

Done review pass (commit 1)

case BoundKind.AssignmentOperator:
var assignment = (BoundAssignmentOperator)expression;
if (assignment.IsRef &&
assignment is not { Left.Kind: BoundKind.Local, Right.Kind: BoundKind.ArrayAccess }) // Optimize for some known to be safe scenarios.
Copy link
Member

@333fred 333fred Jan 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What drives the need to optimize? Do we think this is especially common? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What drives the need to optimize? Do we think this is especially common?

  • Laziness. Don't want to update IL baselines for tests.
  • The IL is actually becomes bigger, less optimal.

@"
125
").VerifyDiagnostics();
}
Copy link
Member

@333fred 333fred Jan 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth testing with some slicing as well: Something like arr[1..][^1] to ensure that the slice rewriting bits are working as well. #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth testing with some slicing as well: Something like arr[1..][^1] to ensure that the slice rewriting bits are working as well.

I'll add a test. However, a scenario like that isn't interesting for the specific problem I am trying to address in this PR. It doesn't matter how array came to the existence. It is a reference type and it is going to be captured by value. It is the array element (the actual target of the assignment) captured by reference. That is what needs the right spilling.

@AlekseyTs
Copy link
Contributor Author

@333fred, @dotnet/roslyn-compiler Please review.

Copy link
Member

@333fred 333fred left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (commit 2)

@AlekseyTs
Copy link
Contributor Author

@dotnet/roslyn-compiler For the second review.

4 similar comments
@AlekseyTs
Copy link
Contributor Author

@dotnet/roslyn-compiler For the second review.

@AlekseyTs
Copy link
Contributor Author

@dotnet/roslyn-compiler For the second review.

@AlekseyTs
Copy link
Contributor Author

@dotnet/roslyn-compiler For the second review.

@AlekseyTs
Copy link
Contributor Author

@dotnet/roslyn-compiler For the second review.

@AlekseyTs AlekseyTs merged commit f51c1b2 into dotnet:main Jan 10, 2022
@ghost ghost added this to the Next milestone Jan 10, 2022
333fred added a commit to 333fred/roslyn that referenced this pull request Jan 11, 2022
dotnet#58657 was also a fix for 58514, by forcing the compiler to spill sequences in this scenario as well. This just adds tests to verify the scenario is addressed.

Fixes dotnet#58514.
333fred pushed a commit to 333fred/roslyn that referenced this pull request Jan 11, 2022
333fred added a commit that referenced this pull request Jan 20, 2022
#58657 was also a fix for 58514, by forcing the compiler to spill sequences in this scenario as well. This just adds tests to verify the scenario is addressed.

Fixes #58514.
333fred added a commit that referenced this pull request Jan 21, 2022
…re spilled. (#58657) (#58788)

Fixes #58569.

(cherry picked from commit f51c1b2)

Co-authored-by: AlekseyTs <AlekseyTs@users.noreply.github.com>
333fred added a commit that referenced this pull request Jan 24, 2022
…merges/release/dev17.1-vs-deps-to-main

* upstream/release/dev17.1-vs-deps:
  Cleanup missed suggestion
  Update src/Workspaces/Core/Portable/Classification/ClassifierHelper.cs
  SpillSequenceSpiller.Spill - ensure sequences under ref assignments are spilled. (#58657) (#58788)
  Correctly update the list of generators for a call to WithAnalyzerReferences
  Rename parameter for what it's actually doing
  Handle AdditiveSpans in either order
  Reduce Stack Trace Explorer automatic open behavior scope (#58819)
  Revert 58892 (#58930)
  Mark APIs as shipped (#58776)
  Revert "Merge pull request #57132 from CyrusNajmabadi/branchId3"
  Fix race in WorkCoordinator when handling document reanalysis
  Remove unnecessary lock access setting UIContexts in the workspace
@RikkiGibson RikkiGibson modified the milestones: Next, 17.2.P1 Feb 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment