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

Add: Ignore unreferenced named parameters #151

Merged
merged 2 commits into from Oct 1, 2020
Merged

Conversation

@glx22
Copy link
Contributor

@glx22 glx22 commented May 23, 2020

When a named parameter is defined, it consumes an actionD register, even if it's never accessed later.

This PR solves that by reference counting all identifiers, and assign an actionD register only if it's needed.

The check is not recursive, a named parameter referenced only by an unreferenced one won't be ignored. Same for write only named parameters written multiple times. But I think these cases should not be common.

@glx22 glx22 force-pushed the glx22:identifiers branch from dd4bc14 to 1a82d99 May 24, 2020
It's not recursive, a param referenced only by a unreferenced one won't be ignored.
@glx22 glx22 force-pushed the glx22:identifiers branch from 1a82d99 to cab6d28 May 24, 2020
Copy link
Contributor

@FLHerne FLHerne left a comment

Looks good to me, Eddi's potential issue aside.

I suspect the simple refcounting can have some false negatives, because of Identifiers being used for other things, but that shouldn't be a problem.

@glx22
Copy link
Contributor Author

@glx22 glx22 commented May 24, 2020

Yeah it's a very basic optimisation, but it should handle all simple cases and free some actionD registers.

Anyway, please do not merge this PR before @Eddi-z can test it :)

@LordAro LordAro merged commit 3add620 into OpenTTD:master Oct 1, 2020
16 checks passed
16 checks passed
Python 3.5 on ubuntu-latest
Details
Python 3.x on ubuntu-latest
Details
Python 3.6 on ubuntu-latest
Details
Python 3.x on macOS-latest
Details
Python 3.7 on ubuntu-latest
Details
Python 3.x on windows-2016
Details
Python 3.8 on ubuntu-latest
Details
Python pypy3 on ubuntu-latest
Details
Python 3.5 on macOS-latest
Details
Python 3.6 on macOS-latest
Details
Python 3.7 on macOS-latest
Details
Python 3.8 on macOS-latest
Details
Python 3.5 on windows-2016
Details
Python 3.6 on windows-2016
Details
Python 3.7 on windows-2016
Details
Python 3.8 on windows-2016
Details
@glx22 glx22 deleted the glx22:identifiers branch Oct 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants