Commit Graph

4309 Commits

Author SHA1 Message Date
bjorn3
593228373d Remove workaround for UB in cranelift-jit that has been fixed 2024-03-22 18:58:36 +00:00
bjorn3
e2cc8ebd87 Rustup to rustc 1.79.0-nightly (0ad927c0c 2024-03-21) 2024-03-22 18:51:59 +00:00
bjorn3
087385a1e7 Sync from rust 0ad927c0c0 2024-03-22 18:44:52 +00:00
bjorn3
ae0e6e22f0 Update to Cranelift 0.106 2024-03-22 18:34:00 +00:00
bors
9057355f50 Auto merge of #122580 - saethlin:compiler-builtins-can-panic, r=pnkfelix
"Handle" calls to upstream monomorphizations in compiler_builtins

This is pretty cooked, but I think it works.

compiler-builtins has a long-standing problem that at link time, its rlib cannot contain any calls to `core`. And yet, in codegen we _love_ inserting calls to symbols in `core`, generally from various panic entrypoints.

I intend this PR to attack that problem as completely as possible. When we generate a function call, we now check if we are generating a function call from `compiler_builtins` and whether the callee is a function which was not lowered in the current crate, meaning we will have to link to it.

If those conditions are met, actually generating the call is asking for a linker error. So we don't. If the callee diverges, we lower to an abort with the same behavior as `core::intrinsics::abort`. If the callee does not diverge, we produce an error. This means that compiler-builtins can contain panics, but they'll SIGILL instead of panicking. I made non-diverging calls a compile error because I'm guessing that they'd mostly get into compiler-builtins by someone making a mistake while working on the crate, and compile errors are better than linker errors. We could turn such calls into aborts as well if that's preferred.
2024-03-22 16:55:11 +00:00
Michael Goulet
155b46aeb2 Programmatically convert some of the pat ctors 2024-03-22 11:13:29 -04:00
Michael Goulet
dfc1bd7516 Eagerly convert some ctors to use their specialized ctors 2024-03-22 11:12:01 -04:00
Mark Rousskov
05783c8ed6 Codegen const panic messages as function calls
This skips emitting extra arguments at every callsite (of which there
can be many). For a librustc_driver build with overflow checks enabled,
this cuts 0.7MB from the resulting binary.
2024-03-22 09:55:50 -04:00
bjorn3
9ddba16363
Merge pull request #1467 from BeetleFunk/global-asm-ice
Avoid ICE when global_asm const operand fails to evaluate
2024-03-21 23:06:33 +01:00
BeetleFunk
eb752bc6a7 Avoid ICE when global_asm const operand fails to evaluate 2024-03-21 11:59:03 -04:00
Oli Scherer
06ef32c862 Make ptr_guaranteed_cmp a rustc_intrinsic and favor its body over backends implementing it 2024-03-19 09:17:40 +00:00
bjorn3
c49f608062 Several refactorings to constant.rs
* Move the done hash set from ConstantCx to define_all_allocs.
* Move check if alloc has already been defined to the start of the loop.
* Extract helper function for vtables.
2024-03-18 15:10:23 +00:00
bjorn3
b64079d631 Re-enable rmake.rs tests as a compiletest bug has been fixed 2024-03-18 14:08:59 +00:00
bjorn3
1aac27e6b6 Rustup to rustc 1.79.0-nightly (eb45c8444 2024-03-17) 2024-03-18 13:59:53 +00:00
Oli Scherer
eeca87b8c7 Avoid various uses of Option<Span> in favor of using DUMMY_SP in the few cases that used None 2024-03-18 09:34:08 +00:00
Ben Kimock
e46114fdc8 Handle calls to upstream monomorphizations in compiler_builtins 2024-03-16 15:22:05 -04:00
bjorn3
db15302b5d Merge branch 'sync_from_rust' 2024-03-16 17:25:11 +00:00
bjorn3
4b61629951 Merge commit '4cf4ffc6ba514f171b3f52d1c731063e4fc45be3' into sync_cg_clif-2024-03-16 2024-03-16 17:23:11 +00:00
bjorn3
4cf4ffc6ba Fix rustc test suite 2024-03-16 16:30:08 +00:00
bjorn3
e775fdc9e9 Don't try to get a ty for a nested allocation
Fixes rust-lang/rustc_codegen_cranelift#1464
2024-03-16 16:17:58 +00:00
bjorn3
9f162c49cb Rustup to rustc 1.78.0-nightly (c67326b06 2024-03-15) 2024-03-16 16:17:16 +00:00
bjorn3
0000db58c6 Sync from rust c67326b063 2024-03-16 13:25:40 +00:00
Matthias Krüger
47abd3a486 Rollup merge of #122287 - RalfJung:simd-static-assert, r=pnkfelix
add test ensuring simd codegen checks don't run when a static assertion failed

stdarch relies on this to ensure that SIMD indices are in bounds.

I would love to know why this works, but I can't figure out where codegen decides to not codegen a function if a required-const does not evaluate. `@oli-obk` `@bjorn3` do you have any idea?
2024-03-14 15:44:33 +01:00
Jacob Pratt
221402e863 Rollup merge of #121840 - oli-obk:freeze, r=dtolnay
Expose the Freeze trait again (unstably) and forbid implementing it manually

non-emoji version of https://github.com/rust-lang/rust/pull/121501

cc #60715

This trait is useful for generic constants (associated consts of generic traits). See the test (`tests/ui/associated-consts/freeze.rs`) added in this PR for a usage example. The builtin `Freeze` trait is the only way to do it, users cannot work around this issue.

It's also a useful trait for building some very specific abstrations, as shown by the usage by the `zerocopy` crate: https://github.com/google/zerocopy/issues/941

cc ```@RalfJung```

T-lang signed off on reexposing this unstably: https://github.com/rust-lang/rust/pull/121501#issuecomment-1969827742
2024-03-11 03:47:19 -04:00
Ralf Jung
fe7be63dae add comments explaining where post-mono const eval errors abort compilation 2024-03-10 14:39:26 +01:00
Ralf Jung
01affeb53a use Instance::expect_resolve() instead of unwraping Instance::resolve() 2024-03-10 11:49:33 +01:00
bors
ef862a707b Auto merge of #121662 - saethlin:precondition-unification, r=RalfJung
Distinguish between library and lang UB in assert_unsafe_precondition

As described in https://github.com/rust-lang/rust/pull/121583#issuecomment-1963168186, `assert_unsafe_precondition` now explicitly distinguishes between language UB (conditions we explicitly optimize on) and library UB (things we document you shouldn't do, and maybe some library internals assume you don't do).

`debug_assert_nounwind` was originally added to avoid the "only at runtime" aspect of `assert_unsafe_precondition`. Since then the difference between the macros has gotten muddied. This totally revamps the situation.

Now _all_ preconditions shall be checked with `assert_unsafe_precondition`. If you have a precondition that's only checkable at runtime, do a `const_eval_select` hack, as done in this PR.

r? RalfJung
2024-03-10 01:23:54 +00:00
bjorn3
07633821ed Add bcryptprimitives.dll shim for wine 2024-03-09 19:51:11 +00:00
bjorn3
e18201deca Fix rustc test suite 2024-03-09 17:35:49 +00:00
bjorn3
f5a192b736 Rustup to rustc 1.78.0-nightly (46b180ec2 2024-03-08) 2024-03-09 16:20:13 +00:00
Ben Kimock
127c232050 Distinguish between library and lang UB in assert_unsafe_precondition 2024-03-08 18:53:58 -05:00
bjorn3
77dae8c881 Merge branch 'sync_from_rust' 2024-03-08 20:43:24 +00:00
bjorn3
5ec45d3d7a Merge commit '54cbb6e7531f95e086d5c3dd0d5e73bfbe3545ba' into sync_cg_clif-2024-03-08 2024-03-08 20:41:29 +00:00
bjorn3
54cbb6e753 Use sqrt clif instruction for sqrt rust intrinsics 2024-03-08 20:20:45 +00:00
bjorn3
b0809eadef Cleanup .gitignore 2024-03-08 19:52:57 +00:00
bjorn3
da083a8fc2 Remove configuration section from readme
None of these options are available in the rustup version, so it only
has the potential for confusion.
2024-03-08 19:52:51 +00:00
bjorn3
436fce0747 Remove y.rs
It has been deprecated for over a year now.
2024-03-08 19:37:23 +00:00
bjorn3
2b0f51b0b8 Disable Linux MinGW cross-compilation testing for now 2024-03-08 19:02:56 +00:00
bjorn3
6b220e5a2e Disable portable-simd sqrt test on MinGW 2024-03-08 19:02:56 +00:00
bjorn3
4976aa5216 Workaround a couple of bugs in rustc's test suite 2024-03-08 19:02:56 +00:00
bjorn3
5320a800e3 Rustup to rustc 1.78.0-nightly (9c3ad802d 2024-03-07) 2024-03-08 10:22:03 +00:00
bjorn3
dd7117b543 Sync from rust 9c3ad802d9 2024-03-08 10:05:56 +00:00
Matthias Krüger
5ffd498ca1 Rollup merge of #119365 - nbdd0121:asm-goto, r=Amanieu
Add asm goto support to `asm!`

Tracking issue: #119364

This PR implements asm-goto support, using the syntax described in "future possibilities" section of [RFC2873](https://rust-lang.github.io/rfcs/2873-inline-asm.html#asm-goto).

Currently I have only implemented the `label` part, not the `fallthrough` part (i.e. fallthrough is implicit). This doesn't reduce the expressive though, since you can use label-break to get arbitrary control flow or simply set a value and rely on jump threading optimisation to get the desired control flow. I can add that later if deemed necessary.

r? ``@Amanieu``
cc ``@ojeda``
2024-03-08 08:19:17 +01:00
bjorn3
1ace86eb0b Implement all x86 vendor intrinsics used by glam
Fixes rust-lang/rustc_codegen_cranelift#1463
2024-03-06 17:22:12 +01:00
Ralf Jung
804eeff180 only set noalias on Box with the global allocator 2024-03-05 15:03:33 +01:00
Oli Scherer
9277766840 Add a scheme for moving away from extern "rust-intrinsic" entirely 2024-03-04 16:13:50 +00:00
bjorn3
8c46d93ca0 Update to Cranelift 0.105.2
Fixes rust-lang/rustc_codegen_cranelift#1460
2024-02-29 14:55:16 +00:00
Oli Scherer
a11756ca75 Forbid implementing Freeze even if the trait is stabilized 2024-02-29 14:10:29 +00:00
Trevor Gross
e45b4d3209 Add f16 and f128 to rustc_type_ir::FloatTy and rustc_abi::Primitive
Make changes necessary to support these types in the compiler.
2024-02-28 12:58:32 -05:00
bors
c099ed3d1e Auto merge of #121635 - 823984418:remove_archive_builder_lifetime_a, r=nnethercote
Remove useless lifetime of ArchiveBuilder

`trait ArchiveBuilder<'a>` has a seemingly useless lifetime a, so I remove it. If this is intentional, please reject this PR.

```rust
pub trait ArchiveBuilder<'a> {
    fn add_file(&mut self, path: &Path);

    fn add_archive(
        &mut self,
        archive: &Path,
        skip: Box<dyn FnMut(&str) -> bool + 'static>,
    ) -> io::Result<()>;

    fn build(self: Box<Self>, output: &Path) -> bool;
}
```
2024-02-27 03:27:48 +00:00