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

llvm.expect as intrinsics and use it in assert!-like macros #8291

Closed
wants to merge 2 commits into from

Conversation

stepancheg
Copy link
Contributor

Two patches:

1

access llvm.expect.32 and llvm.expect.64 intrinsics as expect32 and expect64 functions in std::unstable::intrinsics module. Module also has likely and unlikely wrappers.

2

Use expect32 function in assert!-like macros.

The patch doesn't provide any visible speed-up, but at least it shouldn't make things worse.

Add two functions to std::unstable::intrinsics module: expect{32,64}
provide access to llvm.expect.{32,64}.

Add `likely` and `unlikely` wrappers to intrinsics module.
@brson
Copy link
Contributor

brson commented Aug 4, 2013

I'm always skeptical about adding features that don't provide any visible advantage. Why do it?

Adding these branch annotations has a pretty notorious reputation in the linux kernel, where they are very often wrong.

Future maintainers will see this and assume it was done for a reason, but what is it?

@stepancheg stepancheg closed this Aug 4, 2013
@stepancheg
Copy link
Contributor Author

@brson probably you are right, discarding pull request.

@thestinger
Copy link
Contributor

I actually need this for something, but LLVM lowers the expect intrinsic in function passes, so it doesn't do anything if implemented as a Rust intrinsic.

flip1995 pushed a commit to flip1995/rust that referenced this pull request Sep 9, 2022
add `--explain` subcommand

This closes rust-lang#8291.

---

changelog: add `cargo clippy -- --explain <lintname>` subcommand
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants