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

Decompilation should prioritize early returns #5666

Open
galenbwill opened this issue Jun 26, 2024 · 1 comment
Open

Decompilation should prioritize early returns #5666

galenbwill opened this issue Jun 26, 2024 · 1 comment
Labels
Component: Core Issue needs changes to the core Core: HLIL Issue involves High Level IL IL Optimization Issue involving optimization of representation (not correctness) Type: Enhancement Issue is a small enhancement to existing functionality

Comments

@galenbwill
Copy link
Contributor

What is the feature you'd like to have?
The the structure of a function's decompilation could be improved by prioritizing early returns in cases like the following:

Current decompilation:

void foo(...) {
    if (argX != 0) {
        // here is whole function body
    }
    return
}

Preferred decompilation:

void foo(...) {
    if (argX == 0) {
        return
    }
    // function body
}

Additional Information:
Question came from @mostobriv on the public slack, with the following text:

is restructuring occurs only when there is multiple expressions in if block?
i've got bunch of examples when i've got nesting of the whole function instead of just early return, with the new option enabled of course.

@galenbwill galenbwill added Type: Enhancement Issue is a small enhancement to existing functionality Core: HLIL Issue involves High Level IL State: Awaiting Triage Issue is waiting for more in-depth triage from a developer labels Jun 26, 2024
@plafosse plafosse added IL Optimization Issue involving optimization of representation (not correctness) Component: Core Issue needs changes to the core and removed State: Awaiting Triage Issue is waiting for more in-depth triage from a developer labels Jul 2, 2024
@galenbwill
Copy link
Contributor Author

From Matt Wiseman on public slack:

Would it be feasible to extend this solution to a new context-menu option on conditionals that allows for inverting and reordering arbitrary conditional scopes, not just in the case of early returns?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Core Issue needs changes to the core Core: HLIL Issue involves High Level IL IL Optimization Issue involving optimization of representation (not correctness) Type: Enhancement Issue is a small enhancement to existing functionality
Projects
None yet
Development

No branches or pull requests

2 participants