Skip to content

Sync from rust 2023 06 11 #282

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

Merged
merged 145 commits into from
Jun 19, 2023
Merged

Sync from rust 2023 06 11 #282

merged 145 commits into from
Jun 19, 2023

Conversation

antoyo
Copy link
Contributor

@antoyo antoyo commented Jun 11, 2023

No description provided.

cuviper and others added 30 commits August 16, 2022 15:46
Now that we require at least LLVM 13, that codegen backend is always
using its intrinsic `fptosi.sat` and `fptoui.sat` conversions, so it
doesn't need the manual implementation. However, the GCC backend still
needs it, so we can move all of that code down there.
Because `PassMode::Cast` is by far the largest variant, but is
relatively rare.

This requires making `PassMode` not impl `Copy`, and `Clone` is no
longer necessary. This causes lots of sigil adjusting, but nothing very
notable.
Currently they try to be very precise. But they are wrong, i.e. they
don't match what's happening in the loop below. This code isn't hot
enough for it to matter that much.
Because it's only ever set to `None` or `Some(Reg::i32())`.
Because it's only needed for that variant. This shrinks the types and
clarifies the logic.
Shrink `FnAbi`

Because they can take up a lot of memory in debug and release builds.

r? `@bjorn3`
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/rust#95643 (comment)

cc `@Gankra` `@scottmcm` `@RalfJung`

r? rust-lang/libs-api
interpret: make read-pointer-as-bytes a CTFE-only error with extra information

Next step in the reaction to rust-lang/rust#99923. Also teaches Miri to implicitly strip provenance in more situations when transmuting pointers to integers, which fixes rust-lang/miri#2456.

Pointer-to-int transmutation during CTFE now produces a message like this:
```
   = help: this code performed an operation that depends on the underlying bytes representing a pointer
   = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
```

r? ``@oli-obk``
Move the cast_float_to_int fallback code to GCC

Now that we require at least LLVM 13, that codegen backend is always
using its intrinsic `fptosi.sat` and `fptoui.sat` conversions, so it
doesn't need the manual implementation. However, the GCC backend still
needs it, so we can move all of that code down there.
bors and others added 19 commits May 30, 2023 10:31
Optimize scalar and scalar pair representations loaded from ByRef in llvm

in rust-lang/rust#105653 I noticed that we were generating suboptimal LLVM IR if we had a `ConstValue::ByRef` that could be represented by a `ScalarPair`. Before rust-lang/rust#105653 this is probably rare, but after it, every slice will go down this suboptimal code path that requires LLVM to untangle a bunch of indirections and translate static allocations that are only used once to read a scalar pair from.
These tend to have special handling in a bunch of places anyway, so the variant helps remember that.  And I think it's easier to grok than non-Scalar Aggregates sometimes being `Immediates` (like I got wrong and caused 109992).  As a minor bonus, it means we don't need to generate poison LLVM values for them to pass around in `OperandValue::Immediate`s.
@antoyo antoyo force-pushed the sync_from_rust_2023_06_11 branch from 2b8a64f to 9483008 Compare June 13, 2023 13:01
@antoyo antoyo force-pushed the sync_from_rust_2023_06_11 branch from 8880d4a to a1c6bf2 Compare June 19, 2023 14:51
@antoyo antoyo force-pushed the sync_from_rust_2023_06_11 branch from a1c6bf2 to 607cbfd Compare June 19, 2023 14:53
@antoyo antoyo merged commit 1bbee3e into master Jun 19, 2023
@antoyo antoyo deleted the sync_from_rust_2023_06_11 branch June 19, 2023 22:45
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.