Uh oh!
There was an error while loading. Please reload this page.
Add pointer masking convenience functions - #96946
Conversation
rust-highfive
commented
May 11, 2022
Some changes occured to rustc_codegen_cranelift cc @bjorn3 Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
WaffleLapkin
commented
May 11, 2022
@rustbot label +T-libs-api -T-libs |
RalfJung
commented
May 11, 2022
Makes sense! Should this be added to the strict provenance feature gate? Also, if/when this lands it'd be great if you could also implement the new intrinsic for Miri. :) |
This comment has been minimized.
This comment has been minimized.
WaffleLapkin
commented
May 11, 2022
I don't really have an opinion on this. While this is mostly useful to mask pointers without touching provenance it may also be used as a shorter version of
Sure, I'll take a look into that! |
There was a problem hiding this comment.
Can someone check that this is valid signature? llvm docs give the following signature:
declareptrty llvm.ptrmask(ptrty %ptr, intty %mask) readnone speculatableAnd the rust intrinsic has the following signature:
fnptr_mask<T>(ptr:*constT,mask:usize) -> *constT;Are all of these compatible with each other?
There was a problem hiding this comment.
The LLVM docs confuse me, here. The semantic section says it's possible for the bitwidth of the mask to be different from the pointer size of the target, but that sounds to me like it'd be an overloaded intrinsic, and thus named something like llvm.ptrmask.i64 the same way llvm.cttz.* and friends work. But the name isn't documented the way those ones are...
There was a problem hiding this comment.
Yes, the name would be llvm.ptrmask.p0i8.i64 etc.
There was a problem hiding this comment.
If I understood llvm docs correctly, ptrmask is equivalent to just GEP, not GEP in bounds, so this is safe.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
bors
commented
May 19, 2022
☔ The latest upstream changes (presumably #95643) made this pull request unmergeable. Please resolve the merge conflicts. |
JohnCSimon
commented
Jun 20, 2022
this is still waiting on review |
Uh oh!
There was an error while loading. Please reload this page.
bors
commented
Jul 27, 2022
☔ The latest upstream changes (presumably #99802) made this pull request unmergeable. Please resolve the merge conflicts. |
apiraino
commented
Jul 28, 2022
I think this is now waiting for a feedback from |
rustbot
commented
Aug 5, 2022
Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 Some changes occurred in compiler/rustc_codegen_gcc cc @antoyo Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
I couldn't find where exactly it's documented, but apperantly pointers to void type are invalid in llvm - void is only allowed as a return type of functions.
WaffleLapkin
commented
Aug 21, 2022
So, it seems like in the ~1000 commits since I've made this branch llvm was updated bringing opaque pointers with it 😄
It seems it should have been |
Uh oh!
There was an error while loading. Please reload this page.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
scottmcm
commented
Aug 21, 2022
@bors r+ |
bors
commented
Aug 21, 2022
RalfJung
commented
Aug 27, 2022
(testing something) @bors rollup=never |
bors
commented
Aug 28, 2022
bors
commented
Aug 28, 2022
☀️ Test successful - checks-actions |
rust-timer
commented
Aug 28, 2022
Finished benchmarking commit (1e978a3): comparison URL. Overall result: ✅ improvements - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Footnotes |
Add pointer masking convenience functions
This PR adds the following public API:
```rust
impl<T: ?Sized> *const T {
fn mask(self, mask: usize) -> *const T;
}
impl<T: ?Sized> *mut T {
fn mask(self, mask: usize) -> *const T;
}
// mod intrinsics
fn mask<T>(ptr: *const T, mask: usize) -> *const T
```
This is equivalent to `ptr.map_addr(|a| a & mask)` but also uses a cool llvm intrinsic.
Proposed in rust-lang#95643 (comment)
cc `@Gankra` `@scottmcm` `@RalfJung`
r? rust-lang/libs-apiAdd pointer masking convenience functions
This PR adds the following public API:
```rust
impl<T: ?Sized> *const T {
fn mask(self, mask: usize) -> *const T;
}
impl<T: ?Sized> *mut T {
fn mask(self, mask: usize) -> *const T;
}
// mod intrinsics
fn mask<T>(ptr: *const T, mask: usize) -> *const T
```
This is equivalent to `ptr.map_addr(|a| a & mask)` but also uses a cool llvm intrinsic.
Proposed in rust-lang#95643 (comment)
cc `@Gankra` `@scottmcm` `@RalfJung`
r? rust-lang/libs-api
This PR adds the following public API:
This is equivalent to
ptr.map_addr(|a| a & mask)but also uses a cool llvm intrinsic.Proposed in #95643 (comment)
cc @Gankra@scottmcm@RalfJung
r? rust-lang/libs-api