-
Notifications
You must be signed in to change notification settings - Fork 13.7k
add a fallback implementation for the prefetch_*
intrinsics
#145626
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
Conversation
The fallback is to just ignore the arguments. That is a valid implementation because this intrinsic is just a hint. I also added `miri::intrinsic_fallback_is_spec` annotation, so that miri now supports these operations. A prefetch intrinsic call is valid on any pointer.
This comment has been minimized.
This comment has been minimized.
2a54586
to
d25910e
Compare
@bors r+ |
Rollup of 13 pull requests Successful merges: - #139357 (Fix parameter order for `_by()` variants of `min` / `max`/ `minmax` in `std::cmp`) - #140314 (Rustdoc: typecheck scrape-examples.js) - #140794 (mention lint group in default level lint note) - #145006 (Clarify EOF handling for `BufRead::skip_until`) - #145252 (Demote x86_64-apple-darwin to Tier 2 with host tools) - #145359 (Fix bug where `rustdoc-js` tester would not pick the right `search.js` file if there is more than one) - #145381 (Implement feature `int_lowest_highest_one` for integer and NonZero types) - #145417 (std_detect: RISC-V platform guide documentation) - #145531 (Add runtime detection for APX-F and AVX10) - #145619 (`std_detect`: Use `rustc-std-workspace-*` to pull in `compiler-builtins`) - #145622 (Remove the std workspace patch for `compiler-builtins`) - #145623 (Pretty print the name of an future from calling async closure) - #145626 (add a fallback implementation for the `prefetch_*` intrinsics ) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #145626 - folkertdev:prefetch-fallback, r=Amanieu add a fallback implementation for the `prefetch_*` intrinsics related ACP: rust-lang/libs-team#638 The fallback is to just ignore the arguments. That is a valid implementation because this intrinsic is just a hint. I also added the `miri::intrinsic_fallback_is_spec` annotation, so that miri now supports these operations. A prefetch intrinsic call is valid on any pointer. (specifically LLVM guarantees this https://llvm.org/docs/LangRef.html#llvm-prefetch-intrinsic) Next, I made the `LOCALITY` argument a const generic. That argument must be const (otherwise LLVM crashes), but that was not reflected in the type. Finally, with these changes, the intrinsic can be safe and `const` (a prefetch at const evaluation time is just a no-op). cc `@Amanieu` r? `@RalfJung`
@@ -330,10 +330,16 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> { | |||
_ => bug!(), | |||
}; | |||
let ptr = args[0].immediate(); | |||
let locality = fn_args.const_at(1).to_value().valtree.unwrap_leaf().to_u32() as i32; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't you use to_i32()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird, I suspect my autocomplete only showed the unsigned versions? Or I missed the signed versions when looking through the docs somehow.
Anyway, to_i32
would be better, but also only the values 0..4
are supported.
Rollup of 13 pull requests Successful merges: - rust-lang/rust#139357 (Fix parameter order for `_by()` variants of `min` / `max`/ `minmax` in `std::cmp`) - rust-lang/rust#140314 (Rustdoc: typecheck scrape-examples.js) - rust-lang/rust#140794 (mention lint group in default level lint note) - rust-lang/rust#145006 (Clarify EOF handling for `BufRead::skip_until`) - rust-lang/rust#145252 (Demote x86_64-apple-darwin to Tier 2 with host tools) - rust-lang/rust#145359 (Fix bug where `rustdoc-js` tester would not pick the right `search.js` file if there is more than one) - rust-lang/rust#145381 (Implement feature `int_lowest_highest_one` for integer and NonZero types) - rust-lang/rust#145417 (std_detect: RISC-V platform guide documentation) - rust-lang/rust#145531 (Add runtime detection for APX-F and AVX10) - rust-lang/rust#145619 (`std_detect`: Use `rustc-std-workspace-*` to pull in `compiler-builtins`) - rust-lang/rust#145622 (Remove the std workspace patch for `compiler-builtins`) - rust-lang/rust#145623 (Pretty print the name of an future from calling async closure) - rust-lang/rust#145626 (add a fallback implementation for the `prefetch_*` intrinsics ) r? `@ghost` `@rustbot` modify labels: rollup
related ACP: rust-lang/libs-team#638
The fallback is to just ignore the arguments. That is a valid implementation because this intrinsic is just a hint.
I also added the
miri::intrinsic_fallback_is_spec
annotation, so that miri now supports these operations. A prefetch intrinsic call is valid on any pointer. (specifically LLVM guarantees this https://llvm.org/docs/LangRef.html#llvm-prefetch-intrinsic)Next, I made the
LOCALITY
argument a const generic. That argument must be const (otherwise LLVM crashes), but that was not reflected in the type.Finally, with these changes, the intrinsic can be safe and
const
(a prefetch at const evaluation time is just a no-op).cc @Amanieu
r? @RalfJung