Commit Graph

13728 Commits

Author SHA1 Message Date
bors
1bb3a9f67a Auto merge of #121309 - Nilstrieb:inline-all-the-fallbacks, r=oli-obk
Make intrinsic fallback bodies cross-crate inlineable

This change was prompted by the stage1 compiler spending 4% of its time when compiling the polymorphic-recursion MIR opt test in `unlikely`.

Intrinsic fallback bodies like `unlikely` should always be inlined, it's very silly if they are not. To do this, we enable the fallback bodies to be cross-crate inlineable. Not that this matters for our workloads since the compiler never actually _uses_ the "fallback bodies", it just uses whatever was cfg(bootstrap)ped, so I've also added `#[inline]` to those.

See the comments for more information.

r? oli-obk
2024-02-22 12:07:08 +00:00
bors
026b3b8e95 Auto merge of #117174 - Ayush1325:uefi-stdio-improve, r=workingjubilee
Improve UEFI stdio

Fixed some things suggested in last PR: #116207

cc `@dvdhrm`
cc `@nicholasbishop`
2024-02-22 06:01:24 +00:00
bors
c1b478efd3 Auto merge of #121223 - RalfJung:simd-intrinsics, r=Amanieu
intrinsics::simd: add missing functions, avoid UB-triggering fast-math

Turns out stdarch declares a bunch more SIMD intrinsics that are still missing from libcore.
I hope I got the docs and in particular the safety requirements right for these "unordered" and "nanless" intrinsics.

Many of these are unused even in stdarch, but they are implemented in the codegen backend, so we may as well list them here.

r? `@Amanieu`
Cc `@calebzulawski` `@workingjubilee`
2024-02-22 04:02:31 +00:00
bors
c5f69bdd51 Auto merge of #118634 - Jules-Bertholet:box-allocator-static, r=Amanieu
Remove useless `'static` bounds on `Box` allocator

#79327 added `'static` bounds to the allocator parameter for various `Box` + `Pin` APIs to ensure soundness. But it was a bit overzealous, some of the bounds aren't actually needed.
2024-02-22 02:03:29 +00:00
Ralf Jung
07b6240947 remove simd_reduce_{min,max}_nanless 2024-02-21 20:50:47 +01:00
Ralf Jung
b58f647d54 rename ptr::invalid -> ptr::without_provenance
also introduce ptr::dangling matching NonNull::dangling
2024-02-21 20:15:52 +01:00
Ralf Jung
3dc631a61a make simd_reduce_{mul,add}_unordered use only the 'reassoc' flag, not all fast-math flags 2024-02-21 16:28:20 +01:00
Ralf Jung
25fe3cc69d intrinsics::simd: add missing functions 2024-02-21 16:26:32 +01:00
bors
1d447a9946 Auto merge of #121383 - Dylan-DPC:rollup-735p4u4, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #121208 (Convert `delayed_bug`s to `bug`s.)
 - #121288 (make rustc_expand translatable)
 - #121304 (Add docs for extension proc-macro)
 - #121328 (Make --verbose imply -Z write-long-types-to-disk=no)
 - #121338 (Downgrade ambiguous_wide_pointer_comparisons suggestions to MaybeIncorrect)
 - #121361 (diagnostic items for legacy numeric modules)
 - #121375 (Print proper relative path for descriptive name check)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-21 12:09:22 +00:00
bors
bb8b11e67d Auto merge of #120718 - saethlin:reasonable-fast-math, r=nnethercote
Add "algebraic" fast-math intrinsics, based on fast-math ops that cannot return poison

Setting all of LLVM's fast-math flags makes our fast-math intrinsics very dangerous, because some inputs are UB. This set of flags permits common algebraic transformations, but according to the [LangRef](https://llvm.org/docs/LangRef.html#fastmath), only the flags `nnan` (no nans) and `ninf` (no infs) can produce poison.

And this uses the algebraic float ops to fix https://github.com/rust-lang/rust/issues/120720

cc `@orlp`
2024-02-21 09:43:33 +00:00
Dylan DPC
860ad7c10b
Rollup merge of #121361 - pitaj:diag_items-legacy_numeric_constants, r=Nilstrieb
diagnostic items for legacy numeric modules

For https://github.com/rust-lang/rust-clippy/pull/12312

Missed these in #121272

r? `@Nilstrieb`
2024-02-21 08:55:58 +00:00
Peter Jaszkowiak
0195f21f72 diagnostic items for legacy numeric modules 2024-02-20 13:34:18 -07:00
Matthias Krüger
c03f61ba69
Rollup merge of #121352 - malobre:patch-1, r=Nilstrieb
docs: add missing "the" to `str::strip_prefix` doc

Fix #121348
2024-02-20 19:35:42 +01:00
Matthias Krüger
3099a7931a
Rollup merge of #121277 - reitermarkus:generic-nonzero-convert-num, r=dtolnay
Refactor trait implementations in `core::convert::num`.

Tracking issue: https://github.com/rust-lang/rust/issues/120257

Implement conversion traits using generic `NonZero` type, and refactor all macros to use a consistent format/order of parameters.

r? `@dtolnay`
2024-02-20 19:35:40 +01:00
Matthias Krüger
fc5f6f88e5
Rollup merge of #119203 - farnoy:simd-masked-intrinsic-docfix, r=RalfJung
Correct the simd_masked_{load,store} intrinsic docs

Explains the uniform pointer being used for these two operations and how elements are offset from it.
2024-02-20 19:35:39 +01:00
Ben Kimock
cc73b71e8e Add "algebraic" versions of the fast-math intrinsics 2024-02-20 12:39:03 -05:00
Malobre
9ac73cbdc6
docs: add missing "the" to str::strip_prefix doc 2024-02-20 18:05:55 +01:00
bors
bb594538fc Auto merge of #121345 - Nilstrieb:rollup-reb0xge, r=Nilstrieb
Rollup of 8 pull requests

Successful merges:

 - #121167 (resolve: Scale back unloading of speculatively loaded crates)
 - #121196 (Always inline check in `assert_unsafe_precondition` with cfg(debug_assertions))
 - #121241 (Implement `NonZero` traits generically.)
 - #121278 (Remove the "codegen" profile from bootstrap)
 - #121286 (Rename `ConstPropLint` to `KnownPanicsLint`)
 - #121291 (target: Revert default to the medium code model on LoongArch targets)
 - #121302 (Remove `RefMutL` hack in `proc_macro::bridge`)
 - #121318 (Trigger `unsafe_code` lint on invocations of `global_asm`)

Failed merges:

 - #121206 (Top level error handling)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-20 16:22:48 +00:00
Jakub Okoński
14a4551695
Correct the simd_masked_{load,store} intrinsic docs 2024-02-20 17:03:24 +01:00
Nilstrieb
739f83d906
Rollup merge of #121302 - GrigorenkoPV:refmutl, r=bjorn3
Remove `RefMutL` hack in `proc_macro::bridge`

From what I can tell, #52812 is now fixed, so there is no longer any need to keep this hack around.
2024-02-20 15:13:54 +01:00
Nilstrieb
f6b4080592
Rollup merge of #121241 - reitermarkus:generic-nonzero-traits, r=dtolnay
Implement `NonZero` traits generically.

Tracking issue: https://github.com/rust-lang/rust/issues/120257

r? ````@dtolnay````
2024-02-20 15:13:52 +01:00
Nilstrieb
4ff6bb51e2
Rollup merge of #121196 - Nilstrieb:the-clever-solution, r=saethlin
Always inline check in `assert_unsafe_precondition` with cfg(debug_assertions)

The current complexities in `assert_unsafe_precondition` are delicately balancing several concerns, among them compile times for the cases where there are no debug assertions. This comes at a large runtime cost when the assertions are enabled, making the debug assertion compiler a lot slower, which is very annoying.

To avoid this, we always inline the check when building with debug assertions.

Numbers (compiling stage1 library after touching core):
- master: 80s
- just adding `#[inline(always)]` to the `cfg(bootstrap)` `debug_assertions` (equivalent to a bootstrap bump (uhh, i just realized that i was on a slightly outdated master so this bump might have happened already), (#121112)): 67s
- this: 54s

So this seems like a good solution. I think we can still get the same run-time perf improvements for other users too by massaging this code further (see my other PR about adding `#[rustc_no_mir_inline]` #121114) but this is a simpler step that solves the imminent problem of "holy shit my rustc is sooo slow".

Funny consequence: This now means compiling the standard library with dbeug assertions makes it faster (than without, when using debug assertions downstream)!

r? ```@saethlin``` (or anyone else if someone wants to review this)

fixes #121110, supposedly
2024-02-20 15:13:51 +01:00
bors
2b43e75c98 Auto merge of #120863 - saethlin:slice-get-checked, r=the8472
Use intrinsics::debug_assertions in debug_assert_nounwind

This is the first item in https://github.com/rust-lang/rust/issues/120848.

Based on the benchmarking in this PR, it looks like, for the programs in our benchmark suite, enabling all these additional checks does not introduce significant compile-time overhead, with the single exception of `Alignment::new_unchecked`. Therefore, I've added `#[cfg(debug_assertions)]` to that one call site, so that it remains compiled out in the distributed standard library.

The trailing commas in the previous calls to `debug_assert_nounwind!` were causing the macro to expand to `panic_nouwnind_fmt`, which requires more work to set up its arguments, and that overhead alone is measured between this perf run and the next: https://github.com/rust-lang/rust/pull/120863#issuecomment-1937423502
2024-02-20 14:04:57 +00:00
Nilstrieb
9788b192bb
Rollup merge of #121311 - Nilstrieb:is-it-overlapping, r=saethlin
Make `is_nonoverlapping` `#[inline]`

It showed up with 3% execution time in a compiler profile.

backlink to #120848

r? ``@saethlin``
2024-02-20 07:35:48 +01:00
Nilstrieb
dcb7c6919f
Rollup merge of #121310 - GrigorenkoPV:doc-smallfix, r=Nilstrieb
Remove an old hack for rustdoc

Since #78696 has been resolved
2024-02-20 07:35:48 +01:00
Ben Kimock
4a12f82785 Add more inline(always) to fix opt-level=z test on wasm32 2024-02-19 20:38:11 -05:00
Ben Kimock
581e171773 Convert debug_assert_nounwind to intrinsics::debug_assertions 2024-02-19 20:38:09 -05:00
bors
3246e79513 Auto merge of #121185 - GuillaumeGomez:update-stdarch, r=Amanieu
Update stdarch submodule

I'm syncing the rustc_codegen_gcc backend currently and it seems that the new rustc version we use is not happy with the current stdarch submodule version: https://github.com/rust-lang/rustc_codegen_gcc/actions/runs/7930753019/job/21653642490?pr=439

r? `@Amanieu`
2024-02-19 20:04:07 +00:00
Nilstrieb
0b59748807 Make is_nonoverlapping #[inline]
It showed up with 3% execution time in a compiler profile.
2024-02-19 19:28:04 +01:00
Nilstrieb
0f4925e436 Make intrinsic fallback bodies cross-crate inlineable
This change was prompted by the stage1 compiler spending 4% of its time
when compiling the polymorphic-recursion MIR opt test in `unlikely`.

Intrinsic fallback bodies like `unlikely` should always be inlined, it's
very silly if they are not. To do this, we enable the fallback bodies to
be cross-crate inlineable. Not that this matters for our workloads since
the compiler never actually _uses_ the "fallback bodies", it just uses
whatever was cfg(bootstrap)ped, so I've also added `#[inline]` to those.
2024-02-19 19:25:20 +01:00
Pavel Grigorenko
ac1754beb8
Remove an old hack for rustdoc 2024-02-19 21:16:27 +03:00
bors
ccb1415eac Auto merge of #121177 - joboet:move_pal_locks, r=ChrisDenton
Move locks to `sys`

Part of #117276.

r? `@ChrisDenton`
2024-02-19 18:04:28 +00:00
Nilstrieb
03d03c666c Always inline check in assert_unsafe_precondition with cfg(debug_assertions)
The current complexities in `assert_unsafe_precondition` are delicately
balancing several concerns, among them compile times for the cases where
there are no debug assertions. This comes at a large runtime cost when
the assertions are enabled, making the debug assertion compiler a lot
slower, which is very annoying.

To avoid this, we always inline the check when building with debug
assertions.

Numbers (compiling stage1 library after touching core):
- master: 80s
- just adding `#[inline(always)]` to the `cfg(bootstrap)`
  `debug_assertions`: 67s
- this: 54s

So this seems like a good solution. I think we can still get
the same run-time perf improvements for other users too by
massaging this code further (see my other PR about adding
`#[rustc_no_mir_inline]`) but this is a simpler step that
solves the imminent problem of "holy shit my rustc is sooo slow".

Funny consequence: This now means compiling the standard library with
dbeug assertions makes it faster (than without, when using debug
assertions downstream)!
2024-02-19 17:28:49 +01:00
Pavel Grigorenko
5be3d4bee4
Remove RefMutL hack in proc_macro::bridge 2024-02-19 17:39:25 +03:00
Matthias Krüger
c2cc066761
Rollup merge of #121272 - pitaj:diag_items-legacy_numeric_constants, r=Nilstrieb
Add diagnostic items for legacy numeric constants

For rust-lang/rust-clippy#12312
2024-02-19 13:04:34 +01:00
Matthias Krüger
cf0b36a1c5
Rollup merge of #121041 - Nilstrieb:into-the-future-of-2024, r=Mark-Simulacrum
Add `Future` and `IntoFuture` to the 2024 prelude

Implements rust-lang/rfcs#3509.
2024-02-19 13:04:33 +01:00
Matthias Krüger
c5da0382c8
Rollup merge of #119808 - GnomedDev:encode-charsearcher-size-in-type, r=Mark-Simulacrum
Store core::str::CharSearcher::utf8_size as u8

This is already relied on being smaller than u8 due to the `safety invariant: utf8_size must be less than 5`, so this helps LLVM optimize and maybe improve copies due to padding instead of unused bytes.
2024-02-19 13:04:32 +01:00
Guillaume Gomez
9f3f2cd90a Update stdarch submodule 2024-02-19 10:49:20 +01:00
Markus Reiter
a4d969b30e
Refactor trait implementations in core::convert::num. 2024-02-19 06:03:34 +01:00
bors
bea5bebf3d Auto merge of #105917 - a1phyr:read_chain_more_impls, r=workingjubilee
Specialize some methods of `io::Chain`

This PR specializes the implementation of some methods of `io::Chain`, which could bring performance improvements when using it.
2024-02-19 04:43:54 +00:00
bors
d573564575 Auto merge of #121269 - calebzulawski:sync-portable-simd-2024-02-18, r=Mark-Simulacrum
Portable SIMD subtree update

Syncs nightly to the latest changes from rust-lang/portable-simd

r? `@rust-lang/libs`

Also, fixes #119904 which is now fixed upstream.
2024-02-19 02:34:01 +00:00
bors
61223975d4 Auto merge of #121101 - GnomedDev:dyn-small-c-string, r=Nilstrieb
Reduce monomorphisation bloat in small_c_string

This is a code path usually next to an FFI call, so taking the `dyn` slowdown for the 1159 llvm-line (fat lto, codegen-units 1, release build) drop in my testing program [t2fanrd](https://github.com/GnomedDev/t2fanrd) is worth it imo.
2024-02-18 22:54:22 +00:00
Nilstrieb
bd8a1a417a Add Future and IntoFuture to the 2024 prelude
Implements RFC 3509.
2024-02-18 23:20:05 +01:00
Peter Jaszkowiak
d9c1c73d2c diagnostic items for legacy numeric constants 2024-02-18 12:08:16 -07:00
David Thomas
dbb15fb45d
Dyn erase at call site 2024-02-18 17:58:52 +00:00
David Thomas
0433439433
Add some comments to prevent regression 2024-02-18 17:57:13 +00:00
David Thomas
8daf137543
Reduce monomorphisation bloat in small_c_string 2024-02-18 17:57:12 +00:00
Matthias Krüger
5c03d0f422
Rollup merge of #121266 - SabrinaJewson:easy-syscall-aliases, r=Mark-Simulacrum
Add uncontroversial syscall doc aliases to std docs

This PR contains the parts of #113891 that don’t break the doc alias policy.

r? `@Mark-Simulacrum`
2024-02-18 18:54:35 +01:00
Matthias Krüger
c8f2a00aec
Rollup merge of #121224 - hi-rustin:rustin-patch-unit-binding, r=Mark-Simulacrum
Remove unnecessary unit binding

It appears that the unit binding is not necessary at this time. However, I am unsure of its importance in the past. Please let me know if it is unsafe to remove.
2024-02-18 18:54:33 +01:00
Matthias Krüger
99560a428a
Rollup merge of #118569 - blyxxyz:platform-os-str-slice, r=Mark-Simulacrum
Move `OsStr::slice_encoded_bytes` validation to platform modules

This delegates OS string slicing (`OsStr::slice_encoded_bytes`) validation to the underlying platform implementation. For now that results in increased performance and better error messages on Windows without any changes to semantics. In the future we may want to provide different semantics for different platforms.

The existing implementation is still used on Unix and most other platforms and is now optimized a little better.

Tracking issue: https://github.com/rust-lang/rust/issues/118485

cc `@epage,` `@BurntSushi`
2024-02-18 18:54:32 +01:00