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

mark borrowed pointer parameters without a named lifetime as nocapture #6751

Closed
thestinger opened this issue May 26, 2013 · 4 comments
Closed
Labels
A-lifetimes Area: Lifetimes / regions 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

@thestinger
Copy link
Contributor

From the LLVM documentation:

nocapture
This indicates that the callee does not make any copies of the pointer that outlive the callee itself. This is not a valid attribute for return values.

@nikomatsakis: is this a sane optimization? it seems so

@nikomatsakis
Copy link
Contributor

Yes, this should be valid.

@Aatch
Copy link
Contributor

Aatch commented May 29, 2013

We could do this, but it is worth nothing that the LLVM optimizations are able to infer this most of the time.

@pnkfelix
Copy link
Member

visiting for triage, email from 2013 sep 09.

Seems like a potentially simple thing to try out, see how it goes.

(one potential caveat is that if we did just rely on LLVM optimizations to infer this, then we wouldn't have to worry about the nocapture marking getting invalidated by unsafe code. Of course unsafe code probably shouldn't be capturing the values of borrowed pointers anyway...)

@thestinger
Copy link
Contributor Author

It looks like nocapture might end up being how escape analysis will be implemented in LLVM, so this will get more important.

flip1995 pushed a commit to flip1995/rust that referenced this issue Oct 6, 2022
…endoo

Implement `manual_clamp` lint

Fixes rust-lang#9477
Fixes rust-lang#6751

Identifies common patterns where usage of the `clamp` function would be more succinct and clear, and suggests using the `clamp` function instead.

changelog: [`manual_clamp`]: Implement manual_clamp lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lifetimes Area: Lifetimes / regions 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

Successfully merging a pull request may close this issue.

4 participants