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

Make return duplication in ControlFlowSimplification less aggressive #2972

Conversation

ElektroKill
Copy link
Contributor

Link to issue(s) this covers:
Fixes #2924

Problem

ILSpy was a bit too aggressive when it came to duplicating return blocks which resulted in unoptimal and confusing code with tons of unnecessary return statements which differed from the original source code used to produce the binary. For examples see #2924 (comment) and #2924 (comment).

Solution

  • Make the return block duplication step in ControlFlowSimplification less aggressive by effectively making it only perform the duplication if the incoming edge count was 1. This effectively turned it into a simple movement of a block from one container to another.

@dgrunwald
Copy link
Member

Can you add a pretty test that demonstrates this improvement?

@siegfriedpammer siegfriedpammer merged commit 4aca5ab into icsharpcode:master May 6, 2023
@siegfriedpammer
Copy link
Member

Thank you for the contribution. Sorry for taking so long to get to this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ILSpy produces code with a redundant return statement not present in the CIL code
3 participants