-
Notifications
You must be signed in to change notification settings - Fork 128
Implements constant return value propagation for methods with parameters #1998
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
Conversation
|
I remember we discussed this a lot when we added the existing limited support for methods with parameters - and there was a relatively good reason not to do better. What is the use case for this - where do we need it? I think this needs a good reason to add and probably lot more tests. |
|
I can't come up with examples of when ref parameters specifically would be risky, but the |
We cannot evaluate as much as we could even for dotnet/runtime code. For example with this change, this condition can be now removed because it calls into method which couldn't be evaluated as const returning before.
Where do you see the risk? The logic for computing the constant value abort when argument value is used I'd like to understand what could be risky here.
That's not what this change does. It only expands support of return constant value propagation over calls with parameters.
Why is it concerning? This rewrite is done only for the purpose of the return value evaluation. It does not have an effect on the final IL.
I originally wanted but as the change is very narrow we already had test coverage for it. Could you please suggest what other tests would you like to see added? |
vitek-karas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add tests for more complex parameters. Things like:
- passing a return value of a method as a param
- conditions in the param
And set it up such that we have to try to get "past" it - that is make this complex thing the last one pushed on the stack and make sure there's something else before it. You added code for going backwards finding all the parameter setup instructions, but the tests all use simple constants and fields only.
|
What is the impact of this change - how much does it help? (just curious) |
Added a few more, let me know if there is some other interesting il patter to cover
There are already some tests, see e.g. https://github.com/marek-safar/linker/blob/constprop/test/Mono.Linker.Tests.Cases/UnreachableBlock/MethodWithParametersSubstitutions.cs#L145
Low single digit Kb for console app but we are experimenting with more stuff for Xamarin which could benefit from this too |
…ers (dotnet/linker#1998) Commit migrated from dotnet/linker@7951067
No description provided.