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

codegen: optimize returning an argument #33829

Merged
merged 1 commit into from
Nov 18, 2019
Merged

Conversation

vtjnash
Copy link
Sponsor Member

@vtjnash vtjnash commented Nov 12, 2019

It's not unusual to have code that simply returns an argument. When
used in generic code though, that currently might involve copying the
value to a new box. We sometimes define functions like
identity(nospecialize x) = x to work around that, (which is preferable
anyways for other reasons), but it's better for codegen to also just be
aware of this pattern.

@vtjnash vtjnash added the compiler:codegen Generation of LLVM IR and native code label Nov 12, 2019
@vtjnash vtjnash requested a review from Keno November 12, 2019 19:53
@Keno
Copy link
Member

Keno commented Nov 12, 2019

Seems like a good idea in general, but can we get a codegen test to make sure this doesn't regress?

@vtjnash vtjnash added the needs tests Unit tests are required for this change label Nov 12, 2019
It's not unusual to have code that simply returns an argument.  When
used in generic code though, that currently might involve copying the
value to a new box. We sometimes define functions like
`identity(nospecialize x) = x` to work around that, (which is preferable
anyways for other reasons), but it's better for codegen to also just be
aware of this pattern.
@vtjnash vtjnash removed the needs tests Unit tests are required for this change label Nov 15, 2019
@vtjnash
Copy link
Sponsor Member Author

vtjnash commented Nov 15, 2019

@nanosoldier runbenchmarks(ALL, vs=":master")

@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

@vtjnash vtjnash merged commit 9446838 into master Nov 18, 2019
@vtjnash vtjnash deleted the jn/optimize-identity branch November 18, 2019 00:31
KristofferC pushed a commit that referenced this pull request Apr 11, 2020
It's not unusual to have code that simply returns an argument.  When
used in generic code though, that currently might involve copying the
value to a new box. We sometimes define functions like
`identity(nospecialize x) = x` to work around that, (which is preferable
anyways for other reasons), but it's better for codegen to also just be
aware of this pattern.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:codegen Generation of LLVM IR and native code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants