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

Teach LLVM about data ownership #21487

Closed
Aatch opened this issue Jan 21, 2015 · 5 comments
Closed

Teach LLVM about data ownership #21487

Aatch opened this issue Jan 21, 2015 · 5 comments
Labels
A-codegen Area: Code generation A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. I-slow Issue: Problems and improvements with respect to performance of generated code.

Comments

@Aatch
Copy link
Contributor

Aatch commented Jan 21, 2015

Functions that take a non-immediate argument by-value are passed that value by-reference. If the argument needs to live in the current function's frame, we copy it to a local stack slot, but otherwise we'll just re-use the storage that is already there.

Unfortunately, LLVM does not understand that the caller cannot see any of the changes that we might make to the value, behind the passed reference. Since passing an argument by-value either a) copies, meaning that the caller already created a temporary slot, or b) moves, meaning that the slot from the caller is dead once the call returns, LLVM could optimise based on this information, we just need to inform it of that fact.

@huonw huonw added A-codegen Area: Code generation I-slow Issue: Problems and improvements with respect to performance of generated code. labels Jan 22, 2015
@sanxiyn sanxiyn added the A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. label Jan 25, 2015
@dotdash
Copy link
Contributor

dotdash commented Aug 18, 2015

We emit lifetime end intrinsics in the callee for by-value arguments, so LLVM should actually know that the value is dead. Do you have anything else in mind that we should do?

@Aatch
Copy link
Contributor Author

Aatch commented Aug 25, 2015

@dotdash not that I can think of. If LLVM is still missing some optimisations there, that's a separate issue.

I'll investigate some basic cases, but I can't see what else we could do here.

@DemiMarie
Copy link
Contributor

Maybe implement some optimizations in rustc itself?

Since no other widely-used language has Rust's ownership model, optimizations based on it may be in the purview of rustc, rather than llvm (which must serve multiple frontends).

@cyplo
Copy link
Contributor

cyplo commented Jun 1, 2016

Hi ! Is this still an issue ?

@Mark-Simulacrum
Copy link
Member

I believe this is no longer an issue on the LLVM side, and while we can certainly do more optimizations in rustc, there is nothing concrete that could be done to fix this, so I'm going to close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. I-slow Issue: Problems and improvements with respect to performance of generated code.
Projects
None yet
Development

No branches or pull requests

7 participants