Commit Graph

4128 Commits

Author SHA1 Message Date
lcnr
89ab75e856 update use of feature flags 2023-12-14 15:22:37 +01:00
bjorn3
b1c925ba1a Rustup to rustc 1.76.0-nightly (eeff92ad3 2023-12-13) 2023-12-14 13:49:53 +00:00
bjorn3
bb7a126ecd Sync from rust eeff92ad32 2023-12-14 13:26:46 +00:00
bjorn3
45fab3a8bb Rustup to rustc 1.76.0-nightly (3340d49d2 2023-12-12) 2023-12-13 19:10:11 +00:00
bjorn3
b1cd90a423 Sync from rust 3340d49d22 2023-12-13 18:42:21 +00:00
bors
e3d2831ff4 Auto merge of #118534 - RalfJung:extern-type-size-of-val, r=WaffleLapkin
codegen: panic when trying to compute size/align of extern type

The alignment is also computed when accessing a field of extern type at non-zero offset, so we also panic in that case.

Previously `size_of_val` worked because the code path there assumed that "thin pointer" means "sized". But that's not true any more with extern types. The returned size and align are just blatantly wrong, so it seems better to panic than returning wrong results. We use a non-unwinding panic since code probably does not expect size_of_val to panic.
2023-12-13 08:33:05 +00:00
bjorn3
7ec47d1290 Fix rustc test suite 2023-12-12 12:47:28 +00:00
bjorn3
ace694cf83 Rustup to rustc 1.76.0-nightly (06e02d5b2 2023-12-09) 2023-12-12 12:36:10 +00:00
Ralf Jung
aa3dc4c225 remove a cranelift test that doesn't make sense any more 2023-12-12 08:15:17 +01:00
bors
b5c0dd6da2 Auto merge of #117758 - Urgau:lint_pointer_trait_comparisons, r=davidtwco
Add lint against ambiguous wide pointer comparisons

This PR is the resolution of https://github.com/rust-lang/rust/issues/106447 decided in https://github.com/rust-lang/rust/issues/117717 by T-lang.

## `ambiguous_wide_pointer_comparisons`

*warn-by-default*

The `ambiguous_wide_pointer_comparisons` lint checks comparison of `*const/*mut ?Sized` as the operands.

### Example

```rust
let ab = (A, B);
let a = &ab.0 as *const dyn T;
let b = &ab.1 as *const dyn T;

let _ = a == b;
```

### Explanation

The comparison includes metadata which may not be expected.

-------

This PR also drops `clippy::vtable_address_comparisons` which is superseded by this one.

~~One thing: is the current naming right? `invalid` seems a bit too much.~~

Fixes https://github.com/rust-lang/rust/issues/117717
2023-12-11 14:33:16 +00:00
bjorn3
fc1b10c72c Sync from rust 06e02d5b25 2023-12-10 17:29:53 +00:00
surechen
e6376631cc remove redundant imports
detects redundant imports that can be eliminated.

for #117772 :

In order to facilitate review and modification, split the checking code and
removing redundant imports code into two PR.
2023-12-10 10:56:22 +08:00
Jakub Okoński
8ab225df8b Add simd_masked_{load,store} platform-intrinsics
This maps to the LLVM intrinsics: llvm.masked.load and llvm.masked.store
2023-12-09 12:36:08 +01:00
bjorn3
3ff8e7bd7c Fix rustc test suite 2023-12-07 18:23:39 +00:00
bors
63535997b9 Auto merge of #118324 - RalfJung:ctfe-read-only-pointers, r=saethlin
compile-time evaluation: detect writes through immutable pointers

This has two motivations:
- it unblocks https://github.com/rust-lang/rust/pull/116745 (and therefore takes a big step towards `const_mut_refs` stabilization), because we can now detect if the memory that we find in `const` can be interned as "immutable"
- it would detect the UB that was uncovered in https://github.com/rust-lang/rust/pull/117905, which was caused by accidental stabilization of `copy` functions in `const` that can only be called with UB

When UB is detected, we emit a future-compat warn-by-default lint. This is not a breaking change, so completely in line with [the const-UB RFC](https://rust-lang.github.io/rfcs/3016-const-ub.html), meaning we don't need t-lang FCP here. I made the lint immediately show up for dependencies since it is nearly impossible to even trigger this lint without `const_mut_refs` -- the accidentally stabilized `copy` functions are the only way this can happen, so the crates that popped up in #117905 are the only causes of such UB (in the code that crater covers), and the three cases of UB that we know about have all been fixed in their respective crates already.

The way this is implemented is by making use of the fact that our interpreter is already generic over the notion of provenance. For CTFE we now use the new `CtfeProvenance` type which is conceptually an `AllocId` plus a boolean `immutable` flag (but packed for a more efficient representation). This means we can mark a pointer as immutable when it is created as a shared reference. The flag will be propagated to all pointers derived from this one. We can then check the immutable flag on each write to reject writes through immutable pointers.

I just hope perf works out.
2023-12-07 18:11:01 +00:00
bjorn3
1095e0165c Fix testing of portable-simd 2023-12-07 16:49:01 +00:00
Ralf Jung
994d36bac0 ctfe interpreter: extend provenance so that it can track whether a pointer is immutable 2023-12-07 17:46:36 +01:00
bjorn3
3e81adeb12 Rustup to rustc 1.76.0-nightly (1fdfe1234 2023-12-06) 2023-12-07 14:29:06 +00:00
bjorn3
2559532a35 Sync from rust 1fdfe12347 2023-12-07 14:19:46 +00:00
Urgau
9d9459a6f9 Adjust tests for newly added ambiguous_wide_pointer_comparisons lint 2023-12-06 09:03:48 +01:00
Nicholas Nethercote
0657c1b932 Give Handler::fatal and Session::fatal the same return type.
Currently, `Handler::fatal` returns `FatalError`. But `Session::fatal`
returns `!`, because it calls `Handler::fatal` and then calls `raise` on
the result. This inconsistency is unfortunate.

This commit changes `Handler::fatal` to do the `raise` itself, changing
its return type to `!`. This is safe because there are only two calls to
`Handler::fatal`, one in `rustc_session` and one in
`rustc_codegen_cranelift`, and they both call `raise` on the result.

`HandlerInner::fatal` still returns `FatalError`, so I renamed it
`fatal_no_raise` to emphasise the return type difference.
2023-12-04 15:42:06 +11:00
bjorn3
db91a41537
Merge pull request #1432 from simonbuchan/windows-y-wrappers
Add Windows wrappers for ./y
2023-11-29 13:43:39 +01:00
bjorn3
f5a74dc9d0 Add missing trailing newline in y.cmd 2023-11-29 13:42:08 +01:00
Simon Buchan
62dbc19425 Add Windows wrappers for ./y 2023-11-27 21:41:13 +13:00
bors
400cd47c28 Auto merge of #118279 - bjorn3:sync_cg_clif-2023-11-25, r=bjorn3
Subtree sync for rustc_codegen_cranelift

The main highlights this time are implementing a bunch of new vendor intrinsics and fixing some existing ones. And fixing polymorphization for coroutines.

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler
2023-11-25 13:08:29 +00:00
bjorn3
6b82fe231d Merge branch 'sync_from_rust' 2023-11-25 10:08:42 +00:00
bjorn3
1988cf4a18 Merge commit '710c67909d034e1c663174a016ca82b95c2d6c12' into sync_cg_clif-2023-11-25 2023-11-25 10:05:52 +00:00
bjorn3
710c67909d
Merge pull request #1431 from rust-lang/even_more_simd_intrinsics
Implement another batch of vendor intrinsics
2023-11-25 10:57:11 +01:00
bjorn3
86fc533a71 Re-enable rustc test that was disabled due to a rustc bug 2023-11-25 09:40:02 +00:00
bjorn3
da3782a0b4 Rustup to rustc 1.76.0-nightly (37b2813a7 2023-11-24) 2023-11-25 09:32:50 +00:00
bjorn3
85c708132f Sync from rust 37b2813a7b 2023-11-25 09:24:52 +00:00
bjorn3
e6e2f00d21 Fix incorrect implementation of several vendor intrinsics 2023-11-25 09:14:37 +00:00
bjorn3
3b49b9efd5 Implement the int part of the gather family vendor intrinsics 2023-11-24 20:45:22 +01:00
bjorn3
d5a7ae7976 Implement the float part of the gather family vendor intrinsics 2023-11-24 20:45:22 +01:00
bjorn3
c8729e9216 Implement _mm256_zeroupper vendor intrinsic 2023-11-24 20:45:22 +01:00
bjorn3
65da671694 Implement *fmaddsub_p*, *fmsubadd_p* and *fnmadd_p* vendor intrinsics 2023-11-24 20:45:22 +01:00
bjorn3
705031d017 Implement _mm_cvttps_epi32 2023-11-24 20:45:22 +01:00
David Tolnay
abf08329bb Replace option.map(cond) == Some(true) with option.is_some_and(cond) 2023-11-24 09:14:09 -08:00
bjorn3
3ec8d7aa4a Implement _mm_cmpestri and _mm_cmpestrm using inline asm 2023-11-24 13:39:51 +00:00
bjorn3
9c958196e7 Fix polymorphization for coroutines
Fixes rust-lang/rustc_codegen_cranelift#1429
2023-11-24 10:46:22 +01:00
bjorn3
430ab4e923 Allow function pointers in CValue::const_val
Fixes rust-lang/rustc_codegen_cranelift#1430
2023-11-24 10:22:59 +01:00
bjorn3
4ae658683f Fix fn_sig_for_fn_abi and the coroutine transform for generators
There were three issues previously:
* The self argument was pinned, despite Iterator::next taking an
  unpinned mutable reference.
* A resume argument was passed, despite Iterator::next not having one.
* The return value was CoroutineState<Item, ()> rather than Option<Item>

While these things just so happened to work with the LLVM backend,
cg_clif does much stricter checks when trying to assign a value to a
place. In addition it can't handle the mismatch between the amount of
arguments specified by the FnAbi and the FnSig.
2023-11-23 20:17:19 +00:00
bjorn3
a5fcfad890 Fix _mm_sad_epu8 implementation
Fixes rust-lang/rustc_codegen_cranelift#1426
2023-11-21 17:00:43 +01:00
bjorn3
cd7218aa9f Update Cranelift to 0.102 2023-11-21 12:10:37 +01:00
bjorn3
97ca520c44 check-cfg needs -Zunstable-options 2023-11-16 21:24:33 +00:00
bjorn3
db12abf5e1 Merge branch 'sync_from_rust' 2023-11-16 21:16:53 +00:00
bjorn3
dfc669b74c Merge commit 'def04540a4e2541b995195c752c751295606a388' into sync_cg_clif-2023-11-16 2023-11-16 21:15:07 +00:00
bjorn3
def04540a4 Rustup to rustc 1.76.0-nightly (6b771f6b5 2023-11-15) 2023-11-16 21:06:08 +00:00
bjorn3
d9122c7565 Update reference to bjorn3/rustc_codegen_cranelift 2023-11-16 20:55:49 +00:00
Mark Rousskov
497c17a390 Add check-cfg to cranelift 2023-11-15 21:45:48 -05:00