-
Notifications
You must be signed in to change notification settings - Fork 127
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
Linker substitutions don't optimize as much as they can #1106
Comments
This is not the purpose of this feature/setting. It uses constant propagation to remove unreachable code to reduce the size, it does not do inlining or any other IL optimizations. There are a few reasons for that.
If you use it with release not debug csc mode the code after linking will look like this
We might add an additional pass if this turns in noticeable size saving but right now there are bigger fish to fry. |
@marek-safar, this ends up leaving a number of otherwise "dead" types in the IL as well as the supporting IL for calling those methods (a minimum of 6 bytes of IL per call): I think it would be good to actually remove these calls when we know they only return a constant value so we can do further downstream trimming. |
This has been implemented in net7 |
Sample code:
Substitution xml:
Initial IL:
Post-linked IL:
it seems the optimized C# would be:
But we can do better, I want the optimized C# to look like this:
Desired IL:
The text was updated successfully, but these errors were encountered: