Commit Graph

242 Commits

Author SHA1 Message Date
Matthias Krüger 88160ab94c
Rollup merge of #112096 - workingjubilee:array-unzip, r=scottmcm
Remove array_zip

`[T; N]::zip` is "eager" but most zips are mapped. This causes poor optimization in generated code. This is a fundamental design issue and "zip" is "prime real estate" in terms of function names, so let's free it up again.

- FCP concluded in https://github.com/rust-lang/rust/issues/80094#issuecomment-1468300057
- Closes https://github.com/rust-lang/rust/issues/80094
- Closes https://github.com/rust-lang/rust/issues/103555

Could use review to make sure we aren't losing any essential codegen tests.
r? `@scottmcm`
2023-05-31 07:07:02 +02:00
ScottMcMurray 374f5a8091 Test from_fn autovectorizes 2023-05-30 20:45:40 -07:00
bors 3266c36624 Auto merge of #111768 - oli-obk:pair_const_llvm, r=cjgillot
Optimize scalar and scalar pair representations loaded from ByRef in llvm

in https://github.com/rust-lang/rust/pull/105653 I noticed that we were generating suboptimal LLVM IR if we had a `ConstValue::ByRef` that could be represented by a `ScalarPair`. Before https://github.com/rust-lang/rust/pull/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.
2023-05-30 10:31:10 +00:00
Jubilee Young 472230d192 Remove array_zip
`[T; N]::zip` is "eager" but most zips are mapped.
This causes poor optimization in generated code.
This is a fundamental design issue and "zip" is
"prime real estate" in terms of function names,
so let's free it up again.
2023-05-30 00:40:39 -07:00
Wesley Wiser 019d75b44e Add SafeStack support to rustc
Adds support for LLVM [SafeStack] which provides backward edge control
flow protection by separating the stack into two parts: data which is
only accessed in provable safe ways is allocated on the normal stack
(the "safe stack") and all other data is placed in a separate allocation
(the "unsafe stack").

SafeStack support is enabled by passing `-Zsanitizer=safestack`.

[SafeStack]: https://clang.llvm.org/docs/SafeStack.html
2023-05-26 15:18:54 -04:00
Oli Scherer 164d041e30 Stop creating intermediate places just to immediate convert them to operands 2023-05-26 15:01:29 +00:00
Oli Scherer 5f66c41921 Add regression test 2023-05-26 15:00:31 +00:00
bors a2b1646c59 Auto merge of #86844 - bjorn3:global_alloc_improvements, r=pnkfelix
Support #[global_allocator] without the allocator shim

This makes it possible to use liballoc/libstd in combination with `--emit obj` if you use `#[global_allocator]`. This is what rust-for-linux uses right now and systemd may use in the future. Currently they have to depend on the exact implementation of the allocator shim to create one themself as `--emit obj` doesn't create an allocator shim.

Note that currently the allocator shim also defines the oom error handler, which is normally required too. Once `#![feature(default_alloc_error_handler)]` becomes the only option, this can be avoided. In addition when using only fallible allocator methods and either `--cfg no_global_oom_handling` for liballoc (like rust-for-linux) or `--gc-sections` no references to the oom error handler will exist.

To avoid this feature being insta-stable, you will have to define `__rust_no_alloc_shim_is_unstable` to avoid linker errors.

(Labeling this with both T-compiler and T-lang as it originally involved both an implementation detail and had an insta-stable user facing change. As noted above, the `__rust_no_alloc_shim_is_unstable` symbol requirement should prevent unintended dependence on this unstable feature.)
2023-05-25 16:59:57 +00:00
bors d5699874dc Auto merge of #111882 - matthiaskrgr:rollup-1xyv5mq, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #111427 ([rustdoc][JSON] Use exclusively externally tagged enums in the JSON representation)
 - #111486 (Pretty-print inherent projections correctly)
 - #111722 (Document stack-protector option)
 - #111761 (fix(resolve): not defined `extern crate shadow_name`)
 - #111845 (Update books)
 - #111851 (CFI: Fix encode_region: unexpected ReEarlyBound(0, 'a))
 - #111871 (Migrate GUI colors test to original CSS color format)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-23 18:13:36 +00:00
Matthias Krüger 20b6e5a1d8
Rollup merge of #111851 - rcvalle:rust-cfi-fix-111515, r=bjorn3
CFI: Fix encode_region: unexpected ReEarlyBound(0, 'a)

Fixes #111515 and complements #106547 by adding support for encoding early bound regions and also excluding projections when transforming trait objects' traits into their identities before emitting type checks.
2023-05-23 19:53:43 +02:00
Ramon de C Valle 9bbdfea23c CFI: Fix encode_region: unexpected ReEarlyBound(0, 'a)
Fixes #111515 and complements #106547 by adding support for encoding
early bound regions and also excluding projections when transforming
trait objects' traits into their identities before emitting type checks.
2023-05-23 16:44:03 +00:00
bors 52dd1cde59 Auto merge of #107294 - JamieCunliffe:neon-fp, r=Amanieu
Fix some issues with folded AArch64 features

In #91608 the `fp` feature was removed for AArch64 and folded into the `neon` feature, however disabling the `neon` feature doesn't actually disable the `fp` feature. If my understanding on that thread is correct it should do.

While doing this, I also noticed that disabling some features would disable features that it shouldn't. For instance enabling `sve` will enable `neon`, however, when disabling `sve` it would then also disable `neon`, I wouldn't expect disabling `sve` to also disable `neon`.

cc `@workingjubilee`
2023-05-23 15:30:37 +00:00
Pietro Albini 5f0b677b86
codegen: add needs-unwind to tests that require it 2023-05-23 16:54:35 +02:00
Pietro Albini 292bc548c8
codegen: do not require the uwtables attribute
The attribute is not emitted on targets without unwinding tables.
2023-05-23 16:54:34 +02:00
Pietro Albini dc1ed9ddd7
codegen: allow the dso_local attribute
The attribute is injected into most items when static relocation is
enabled in a target.
2023-05-23 16:54:33 +02:00
Pietro Albini 5fdeae610d
codegen: allow extra attributes to functions when panic=abort
When compiling with panic=abort (or using a target that doesn't have
unwinding support), the compiler adds the "nounwind" attribute to
functions. This results in a different LLVM IR, which results in a #NNN
added after the function name:

    tail call void @bar() #13, !dbg !467
    attributes #13 = { nounwind }

...instead of:

    tail call void @bar(), !dbg !467

This commit changes the matchers to swallow the #NNN, as it's not needed
for these specific tests.
2023-05-23 16:54:30 +02:00
bors b08148f6a7 Auto merge of #111869 - Dylan-DPC:rollup-9pydw08, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #111461 (Fix symbol conflict diagnostic mistakenly being shown instead of missing crate diagnostic)
 - #111579 (Also assume wrap-around discriminants in `as` MIR building)
 - #111704 (Remove return type sized check hack from hir typeck)
 - #111853 (Check opaques for mismatch during writeback)
 - #111854 (rustdoc: clean up `settings.css`)
 - #111860 (Don't ICE if method receiver fails to unify with `arbitrary_self_types`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-23 12:47:51 +00:00
Dylan DPC 00185bec7c
Rollup merge of #111579 - scottmcm:enum-as-signed, r=oli-obk
Also assume wrap-around discriminants in `as` MIR building

Resolves this FIXME:

8d18c32b61/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs (L231)

r? `@oli-obk`
2023-05-23 16:44:27 +05:30
bors f3d597b31c Auto merge of #111807 - erikdesjardins:noalias, r=oli-obk
[rustc_ty_utils] Treat `drop_in_place`'s *mut argument like &mut when adding LLVM attributes

This resurrects PR #103614, which has sat idle for a while.

This could probably use a new perf run, since we're on a new LLVM version now.

r? `@oli-obk`
cc `@RalfJung`

---

LLVM can make use of the `noalias` parameter attribute on the parameter to `drop_in_place` in areas like argument promotion. Because the Rust compiler fully controls the code for `drop_in_place`, it can soundly deduce parameter attributes on it.

In #103957, Miri was changed to retag `drop_in_place`'s argument as if it was `&mut`, matching this change.
2023-05-23 10:12:46 +00:00
Erik Desjardins fb7f1d220c drop-in-place-noalias test: needs -O to ensure attributes are added on nopt builders 2023-05-22 20:20:45 -04:00
bors 2fe47b966a Auto merge of #111634 - marc0246:arc-new-uninit-bloat, r=thomcc
Fix duplicate `arcinner_layout_for_value_layout` calls when using the uninit `Arc` constructors

What this fixes is the duplicate calls to `arcinner_layout_for_value_layout` seen here: https://godbolt.org/z/jr5Gxozhj

The issue was discovered alongside #111603 but is otherwise unrelated to the duplicate `alloca`s, which remain unsolved. Everything I tried to solve said main issue has failed.

As for the duplicate layout calculations, I also tried slapping `#[inline]` and `#[inline(always)]` on everything in sight but the only thing that worked in the end is to dedup the calls by hand.
2023-05-22 15:06:32 +00:00
Jamie Cunliffe a059e68d11 Create a structure to define the features from to_llvm_features.
Rather than returning an array of features from to_llvm_features, return a structure that contains
the dependencies. This also contains metadata on how the features depend on each other to allow for
the correct enabling and disabling.
2023-05-22 14:46:40 +01:00
Jamie Cunliffe d51db4275b Make v8a match optional in the test feature list. 2023-05-22 14:27:14 +01:00
Jamie Cunliffe aab0757c66 Only disable folded features when it makes sense.
Some features that are tied together only make sense to be folded
together when enabling the feature. For example on AArch64 sve and
neon are tied together, however it doesn't make sense to disable neon
when disabling sve.
2023-05-22 14:27:14 +01:00
bors d77014a608 Auto merge of #111697 - rcvalle:rust-cfi-fix-111510, r=bjorn3
CFI: Fix encode_ty: unexpected Param(B/#1)

Fixes #111510 and complements #106547 by adding support for encoding type parameters and also by transforming trait objects' traits into their identities before emitting type checks.
2023-05-21 06:42:05 +00:00
Erik Desjardins c4d69b717f make noalias-box-off filecheck more precise
The CHECK, -NOT, -SAME pattern ensures that the `CHECK-NOT: noalias`
is limited to only one line, and won't match unrelated lines further
down in the file.

Explicit drop call added to preserve the `foo` argument name, since
names of unused arguments are not preserved.
2023-05-20 19:41:28 -04:00
Erik Desjardins 644818351b ensure !Unpin types do not get noalias 2023-05-20 19:34:31 -04:00
Patrick Walton 21b8815b6c Apply `noalias`, `nonnull`, `dereferenceable`, and `align` attributes unconditionally.
We've done measurements with Miri and have determined that `noalias` shouldn't
break code. The requirements that allow us to add dereferenceable and align
have been long documented in the standard library documentation.
2023-05-20 18:12:54 -04:00
Patrick Walton 74dd3cb159 Fix noalias box test 2023-05-20 18:12:54 -04:00
Patrick Walton f71741bac4 [rustc_ty_utils] Add the LLVM `noalias` parameter attribute to `drop_in_place` in certain cases.
LLVM can make use of the `noalias` parameter attribute on the parameter to
`drop_in_place` in areas like argument promotion. Because the Rust compiler
fully controls the code for `drop_in_place`, it can soundly deduce parameter
attributes on it. In the case of a value that has a programmer-defined Drop
implementation, we know that the first thing `drop_in_place` will do is pass a
pointer to the object to `Drop::drop`. `Drop::drop` takes `&mut`, so it must be
guaranteed that there are no pointers to the object upon entering that
function. Therefore, it should be safe to mark `noalias` there.

With this patch, we mark `noalias` only when the type is a value with a
programmer-defined Drop implementation. This is possibly overly conservative,
but I thought that proceeding cautiously was best in this instance.
2023-05-20 18:12:53 -04:00
Scott McMurray 400866b7ab Also assume wrap-around discriminants in `as` MIR building
Resolves this FIXME:

8d18c32b61/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs (L231)
2023-05-18 10:28:36 -07:00
Ramon de C Valle f067935ab2 CFI: Fix encode_ty: unexpected Param(B/#1)
Fixes #111510 and complements #106547 by adding support for encoding
type parameters and also by transforming trait objects' traits into
their identities before emitting type checks.
2023-05-17 22:12:13 +00:00
bors 5c3a3362f8 Auto merge of #111556 - cjgillot:copy-prop-nrvo, r=oli-obk
Merge return place with other locals in CopyProp.

This reintroduces a limited form of NRVO.

r? wg-mir-opt
2023-05-16 22:27:08 +00:00
marc0246 2a466466c7
Fix duplicate `arcinner_layout_for_value_layout` calls 2023-05-16 08:53:05 +02:00
Matthias Krüger e52fbff5e8
Rollup merge of #111525 - scottmcm:slice-position-tweak, r=Mark-Simulacrum
Stop checking for the absence of something that doesn't exist

A couple of codegen tests are doing
```
// CHECK-NOT: slice_index_len_fail
```

However, that function no longer exists: [the only places](https://github.com/search?q=repo%3Arust-lang%2Frust+slice_index_len_fail&type=code) it occurs in the repo are in those tests.

So this PR updates the tests to check for the absense of the functions that are actually used today to panic for out-of-bounds indexing.
2023-05-15 17:12:45 +02:00
Camille GILLOT f40f235879 Merge return place with other locals in CopyProp. 2023-05-14 12:06:34 +00:00
bors 3603a84a3d Auto merge of #111517 - lukas-code:addr-of-mutate, r=tmiasko
allow mutating function args through `&raw const`

Fixes https://github.com/rust-lang/rust/issues/111502 by "turning off the sketchy optimization while we figure out if this is ok", like `@JakobDegen` said.

The first commit in this PR removes some suspicious looking logic from the same method, but should have no functional changes, since it doesn't modify the `context` outside of the method. Best reviewed commit by commit.

r? opsem
2023-05-14 10:45:39 +00:00
Scott McMurray a9570a34cd Stop checking for the absense of something that doesn't exist
A couple of codegen tests are doing
```
// CHECK-NOT: slice_index_len_fail
```

However, that function no longer exists: [the only places](https://github.com/search?q=repo%3Arust-lang%2Frust+slice_index_len_fail&type=code) it occurs in the repo are in those tests.

So this PR updates the tests to check for the absense of the functions that are actually used today to panic for out-of-bounds indexing.
2023-05-12 21:59:26 -07:00
Scott McMurray c50a2e1d17 Remove useless `assume`s from `slice::iter(_mut)` 2023-05-12 17:34:55 -07:00
Lukas Markeffsky 9c418e5170 allow mutating function args through `&raw const` 2023-05-13 00:00:51 +02:00
Michael Goulet 691a5f3883
Rollup merge of #111375 - rcvalle:rust-cfi-fix-106547, r=bjorn3
CFI: Fix SIGILL reached via trait objects

Fix #106547 by transforming the concrete self into a reference to a trait object before emitting type metadata identifiers for trait methods.
2023-05-11 17:43:07 -07:00
bjorn3 34f6a83b28 Fix test 2023-05-11 14:35:10 +00:00
bjorn3 66982a383b Prevent insta-stable no alloc shim support
You will need to add the following as replacement for the old __rust_*
definitions when not using the alloc shim.

    #[no_mangle]
    static __rust_no_alloc_shim_is_unstable: u8 = 0;
2023-05-11 14:35:09 +00:00
Matthias Krüger acae72e493
Rollup merge of #111385 - durin42:vec-panik-17, r=Amanieu
vec-shrink-panik: update expectations to work on LLVM 17

For some reason, the called function is `cleanup` on LLVM 17 instead of `filter`.

r? `@Amanieu`
2023-05-11 07:05:28 +02:00
Augie Fackler fbe479558c vec-shrink-panik: update expectations to work on LLVM 17
For some reason, the called function is `cleanup` on LLVM 17 instead of
`filter`.

r? @Amanieu
2023-05-10 09:31:33 -04:00
Ramon de C Valle 7c7b22e62c CFI: Fix SIGILL reached via trait objects
Fix #106547 by transforming the concrete self into a reference to a
trait object before emitting type metadata identifiers for trait
methods.
2023-05-09 20:04:19 +00:00
Matthias Krüger 273fbf47ab
Rollup merge of #111282 - scottmcm:remove-unneeded-assumes, r=workingjubilee
Remove some `assume`s from slice iterators that don't do anything

Because the start pointer is iterators is already a `NonNull`, we emit the appropriate `!nonnull` metadata when loading the pointer to tell LLVM that it's non-null.

Probably the best way to see that it's the metadata that's important (and not the `assume`) is to observe that LLVM actually *removes* the `assume` from the optimized IR: <https://rust.godbolt.org/z/KhE6G963n>.

(I also checked that, yes, the if-not-ZST `assume` on `end` is still doing something: it's how there's a `!nonnull` metadata on its load, even though it's an ordinary raw pointer.  The codegen test added in this PR fails if the other `assume` is  removed.)
2023-05-09 20:49:33 +02:00
bors 2f2c438dce Auto merge of #111358 - compiler-errors:rollup-yv27vrp, r=compiler-errors
Rollup of 6 pull requests

Successful merges:

 - #104070 (Prevent aborting guard from aborting the process in a forced unwind)
 - #109410 (Introduce `AliasKind::Inherent` for inherent associated types)
 - #111004 (Migrate `mir_transform` to translatable diagnostics)
 - #111118 (Suggest struct when we get colon in fileds in enum)
 - #111170 (Diagnostic args are still args if they're documented)
 - #111354 (Fix miscompilation when calling default methods on `Future`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-08 21:00:50 +00:00
Jakob Degen 8e2da80fc5 Disable nrvo mir opt 2023-05-08 03:55:41 -07:00
Gary Guo 16abe6c83d Fix codegen test 2023-05-07 12:38:47 +01:00
Scott McMurray ec3a9bcdb7 Remove some `assume`s from slice iterators that don't do anything 2023-05-06 00:33:32 -07:00
Scott McMurray a1e5c65aa4 `assume` the runtime range of `align_offset`
Found when I saw code with `align_to` having extraneous checks.
2023-05-05 04:22:51 -07:00
Matthias Krüger ea0b6504fa
Rollup merge of #111009 - scottmcm:ascii-char, r=BurntSushi
Add `ascii::Char` (ACP#179)

ACP second: https://github.com/rust-lang/libs-team/issues/179#issuecomment-1527900570
New tracking issue: https://github.com/rust-lang/rust/issues/110998

For now this is an `enum` as `@kupiakos` [suggested](https://github.com/rust-lang/libs-team/issues/179#issuecomment-1527959724), with the variants under a different feature flag.

There's lots more things that could be added here, and place for further doc updates, but this seems like a plausible starting point PR.

I've gone through and put an `as_ascii` next to every `is_ascii`: on `u8`, `char`, `[u8]`, and `str`.

As a demonstration, made a commit updating some formatting code to use this: https://github.com/scottmcm/rust/commit/ascii-char-in-fmt (I don't want to include that in this PR, though, because that brings in perf questions that don't exist if this is just adding new unstable APIs.)
2023-05-04 19:18:21 +02:00
Scott McMurray 8c781b0906 Add the basic `ascii::Char` type 2023-05-03 22:09:33 -07:00
Manish Goregaokar 09839bfdb1
Rollup merge of #110928 - loongarch-rs:tests, r=petrochenkov
tests: Add tests for LoongArch64
2023-05-03 16:42:49 -07:00
Manish Goregaokar 38bbc39895
Rollup merge of #105452 - rcvalle:rust-cfi-3, r=bjorn3
Add cross-language LLVM CFI support to the Rust compiler

This PR adds cross-language LLVM Control Flow Integrity (CFI) support to the Rust compiler by adding the `-Zsanitizer-cfi-normalize-integers` option to be used with Clang `-fsanitize-cfi-icall-normalize-integers` for normalizing integer types (see https://reviews.llvm.org/D139395).

It provides forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space). For more information about LLVM CFI and cross-language LLVM CFI support for the Rust compiler, see design document in the tracking issue #89653.

Cross-language LLVM CFI can be enabled with -Zsanitizer=cfi and -Zsanitizer-cfi-normalize-integers, and requires proper (i.e., non-rustc) LTO (i.e., -Clinker-plugin-lto).

Thank you again, ``@bjorn3,`` ``@nikic,`` ``@samitolvanen,`` and the Rust community for all the help!
2023-05-03 16:42:48 -07:00
Ramon de C Valle 004aa15b47 Add cross-language LLVM CFI support to the Rust compiler
This commit adds cross-language LLVM Control Flow Integrity (CFI)
support to the Rust compiler by adding the
`-Zsanitizer-cfi-normalize-integers` option to be used with Clang
`-fsanitize-cfi-icall-normalize-integers` for normalizing integer types
(see https://reviews.llvm.org/D139395).

It provides forward-edge control flow protection for C or C++ and Rust
-compiled code "mixed binaries" (i.e., for when C or C++ and Rust
-compiled code share the same virtual address space). For more
information about LLVM CFI and cross-language LLVM CFI support for the
Rust compiler, see design document in the tracking issue #89653.

Cross-language LLVM CFI can be enabled with -Zsanitizer=cfi and
-Zsanitizer-cfi-normalize-integers, and requires proper (i.e.,
non-rustc) LTO (i.e., -Clinker-plugin-lto).
2023-05-03 22:41:29 +00:00
Scott McMurray 5292d48b85 Codegen fewer instructions in `mem::replace` 2023-04-30 22:33:04 -07:00
WANG Rui 4375d3b203 tests: Add tests for LoongArch64 2023-04-30 00:06:26 +08:00
bors f2299490c1 Auto merge of #108106 - the8472:layout-opt, r=wesleywiser
Improve niche placement by trying two strategies and picking the better result

Fixes #104807
Fixes #105371

Determining which sort order is better requires calculating the struct size (so we can calculate the niche offset). But that in turn depends on the field order, so happens after sorting. So the simple way to solve that is to run the whole thing twice and pick the better result.

1st commit is just code motion, the meat is in the later ones.
2023-04-29 08:55:04 +00:00
The 8472 67a835d755 fix codegen test 2023-04-28 23:08:54 +02:00
Scott McMurray e1da77c76d Also use `mir::Offset` for pointer `add` 2023-04-27 22:44:42 -07:00
The 8472 1a51ec6864 bless tests 2023-04-27 22:29:04 +02:00
Matthias Krüger 3ecae2932c
Rollup merge of #110706 - scottmcm:transmute_unchecked, r=oli-obk
Add `intrinsics::transmute_unchecked`

This takes a whole 3 lines in `compiler/` since it lowers to `CastKind::Transmute` in MIR *exactly* the same as the existing `intrinsics::transmute` does, it just doesn't have the fancy checking in `hir_typeck`.

Added to enable experimenting with the request in <https://github.com/rust-lang/rust/pull/106281#issuecomment-1496648190> and because the portable-simd folks might be interested for dependently-sized array-vector conversions.

It also simplifies a couple places in `core`.

See also https://github.com/rust-lang/rust/pull/108442#issuecomment-1474777273, where `CastKind::Transmute` was added having exactly these semantics before the lang meeting (which I wasn't in) independently expressed interest.
2023-04-24 07:53:25 +02:00
Scott McMurray 1de2257c3f Add `intrinsics::transmute_unchecked`
This takes a whole 3 lines in `compiler/` since it lowers to `CastKind::Transmute` in MIR *exactly* the same as the existing `intrinsics::transmute` does, it just doesn't have the fancy checking in `hir_typeck`.

Added to enable experimenting with the request in <https://github.com/rust-lang/rust/pull/106281#issuecomment-1496648190> and because the portable-simd folks might be interested for dependently-sized array-vector conversions.

It also simplifies a couple places in `core`.
2023-04-22 17:22:03 -07:00
Wesley Wiser 4e8b642646 Turn on ConstDebugInfo pass. 2023-04-22 23:41:48 +02:00
bors 7e23d180c1 Auto merge of #109993 - scottmcm:transmute-niches, r=oli-obk
`assume` value ranges in `transmute`

Fixes #109958
2023-04-20 10:46:13 +00:00
Scott McMurray baf98e7515 Add transmute optimization tests and some extra comments 2023-04-19 23:17:35 -07:00
Guillaume Gomez e6b607335a
Rollup merge of #110441 - kadiwa4:typos, r=thomcc
5 little typos
2023-04-18 14:50:51 +02:00
bors 5fe3528be5 Auto merge of #110242 - cuviper:vanilla-llvm-16, r=Mark-Simulacrum
ci: add a runner for vanilla LLVM 16

Like #107044, this will let us track compatibility with LLVM 16 going
forward, especially after we eventually upgrade our own to the next.

This also drops `tidy` here and in `x86_64-gnu-llvm-15`, syncing with
that change in #106085.
2023-04-18 08:38:04 +00:00
Matthias Krüger c81e8b8e18
Rollup merge of #110455 - durin42:tls-D148269-fix, r=nikic
tests: adapt for LLVM change 5b386b864c7619897c51a1da97d78f1cf6f3eff6

The above-mentioned change modified the output of thread-local.rs by changing some variable names. Rather than assume things get put in %0, we capture the variable so the test passes in both the old and new version.
2023-04-17 18:13:37 +02:00
Matthias Krüger eb0524615c
Rollup merge of #110313 - fee1-dead-contrib:repr_align_method, r=WaffleLapkin
allow `repr(align = x)` on inherent methods

Discussion: https://github.com/rust-lang/rust/issues/82232#issuecomment-905929314
2023-04-17 18:13:34 +02:00
Augie Fackler bef3502dba tests: adapt for LLVM change 5b386b864c7619897c51a1da97d78f1cf6f3eff6
The above-mentioned change modified the output of thread-local.rs by
changing some variable names. Rather than assume things get put in %0,
we capture the variable so the test passes in both the old and new
version.
2023-04-17 10:53:18 -04:00
kadiwa 85653831f7
typos 2023-04-17 09:16:07 +02:00
bors 5546cb64f6 Auto merge of #109247 - saethlin:inline-without-inline, r=oli-obk
Permit MIR inlining without #[inline]

I noticed that there are at least a handful of portable-simd functions that have no `#[inline]` but compile to an assign + return.

I locally benchmarked inlining thresholds between 0 and 50 in increments of 5, and 50 seems to be the best. Interesting. That didn't include check builds though, ~maybe perf will have something to say about that~.

Perf has little useful to say about this. We generally regress all the check builds, as best as I can tell, due to a number of small codegen changes in a particular hot function in the compiler. Probably this is because we've nudged the inlining outcomes all over, and uses of `#[inline(always)]`/`#[inline(never)]` might need to be adjusted.
2023-04-17 02:36:38 +00:00
Josh Stone 33036159a4 ci: add a runner for vanilla LLVM 16
Like #107044, this will let us track compatibility with LLVM 16 going
forward, especially after we eventually upgrade our own to the next.

This also drops `tidy` here and in `x86_64-gnu-llvm-15`, syncing with
that change in #106085.
2023-04-16 11:50:20 -07:00
Deadbeef dda89945b7 Allow all associated functions and add test 2023-04-16 06:31:08 +00:00
Camille GILLOT 4a1ff5e04d Bless codegen test. 2023-04-15 07:46:46 +00:00
Camille GILLOT 700084aa97 Update codegen test. 2023-04-14 16:26:11 +00:00
Deadbeef b59ec166ad allow `repr(align = x)` on inherent methods 2023-04-14 06:39:48 +00:00
Scott McMurray 1bcb0ec28c `assume` value ranges in `transmute`
Fixes #109958
2023-04-13 00:12:39 -07:00
bors d8fc819247 Auto merge of #109466 - davidlattimore:inline-arg-via-var-debug-info, r=wesleywiser
Preserve argument indexes when inlining MIR

We store argument indexes on VarDebugInfo. Unlike the previous method of relying on the variable index to know whether a variable is an argument, this survives MIR inlining.

We also no longer check if var.source_info.scope is the outermost scope. When a function gets inlined, the arguments to the inner function will no longer be in the outermost scope. What we care about though is whether they were in the outermost scope prior to inlining, which we know by whether we assigned an argument index.

Fixes #83217

I considered using `Option<NonZeroU16>` instead of `Option<u16>` to store the index. I didn't because `TypeFoldable` isn't implemented for `NonZeroU16` and because it looks like due to padding, it currently wouldn't make any difference. But I indexed from 1 anyway because (a) it'll make it easier if later it becomes worthwhile to use a `NonZeroU16` and because the arguments were previously indexed from 1, so it made for a smaller change.

This is my first PR on rust-lang/rust, so apologies if I've gotten anything not quite right.
2023-04-13 01:51:27 +00:00
bors 13d1802b88 Auto merge of #109895 - nikic:llvm-16-tests, r=cuviper
Add codegen tests for issues fixed by LLVM 16

Fixes #75978.
Fixes #99960.
Fixes #101048.
Fixes #101082.
Fixes #101814.
Fixes #103132.
Fixes #103327.
2023-04-12 02:30:21 +00:00
Nikita Popov 83f525cc28 Make test compatible with 32-bit 2023-04-11 17:19:07 +02:00
Nikita Popov ec635c002b Add ignore-debug to two tests
These don't optimize with debug assertions. For one of them, this
is due to the new alignment checks, for the other I'm not sure
what specifically blocks it.
2023-04-11 11:22:15 +02:00
David Lattimore a6292676eb Preserve argument indexes when inlining MIR
We store argument indexes on VarDebugInfo. Unlike the previous method of
relying on the variable index to know whether a variable is an argument,
this survives MIR inlining.

We also no longer check if var.source_info.scope is the outermost scope.
When a function gets inlined, the arguments to the inner function will
no longer be in the outermost scope. What we care about though is
whether they were in the outermost scope prior to inlining, which we
know by whether we assigned an argument index.
2023-04-11 11:07:48 +10:00
Scott McMurray d757c4b904 Handle not all immediates having `abi::Scalar`s 2023-04-09 11:16:50 -07:00
Ben Kimock e88e2af959 Give the cross-crate generic some work to do 2023-04-07 15:46:45 -04:00
Ben Kimock e3126b1084 Permit MIR inlining without #[inline] 2023-04-07 15:46:43 -04:00
Scott McMurray 454bca514a Check `CastKind::Transmute` sizes in a better way
Fixes #110005
2023-04-06 13:53:10 -07:00
bors 2e486be8d2 Auto merge of #107925 - thomcc:sip13, r=cjgillot
Use SipHash-1-3 instead of SipHash-2-4 for StableHasher

Noticed this, and it seems easy and likely a perf win. IIUC we don't need DDOS resistance (just collision) so we ideally would have an even faster hash, but it's hard to beat this SipHash impl here, since it's been so highly tuned for the interface.

It wouldn't surprise me if there's some subtle reason changing this sucks, as it's so obvious it seems likely to have been done. Still, SipHash-1-3 seems to still have the guarantees StableHasher should need (and seemingly more), and is clearly less work. So it's worth a shot.

Not fully tested locally.
2023-04-05 18:35:34 +00:00
bors b2b676d886 Auto merge of #108905 - ferrocene:pa-compiletest-ignore, r=ehuss
Validate `ignore` and `only` compiletest directive, and add human-readable ignore reasons

This PR adds strict validation for the `ignore` and `only` compiletest directives, failing if an unknown value is provided to them. Doing so uncovered 79 tests in `tests/ui` that had invalid directives, so this PR also fixes them.

Finally, this PR adds human-readable ignore reasons when tests are ignored due to `ignore` or `only` directives, like *"only executed when the architecture is aarch64"* or *"ignored when the operative system is windows"*. This was the original reason why I started working on this PR and #108659, as we need both of them for Ferrocene.

The PR is a draft because the code is extremely inefficient: it calls `rustc --print=cfg --target $target` for every rustc target (to gather the list of allowed ignore values), which on my system takes between 4s and 5s, and performs a lot of allocations of constant values. I'll fix both of them in the coming days.

r? `@ehuss`
2023-04-05 16:15:25 +00:00
Rémy Rakic 931fd8539e Fix codegen tests with hard-coded hashes 2023-04-05 15:59:29 +00:00
Thom Chiovoloni 36ca32c1ed Fix a codegen test with some hard-coded hashes 2023-04-05 15:59:29 +00:00
bors 8d321f7a88 Auto merge of #109843 - scottmcm:better-transmute, r=WaffleLapkin
Allow `transmute`s to produce `OperandValue`s instead of needing `alloca`s

LLVM can usually optimize these away, but especially for things like transmutes of newtypes it's silly to generate the `alloc`+`store`+`load` at all when it's actually a nop at LLVM level.
2023-04-05 03:26:38 +00:00
Scott McMurray 9aa9a846b6 Allow `transmute`s to produce `OperandValue`s instead of always using `alloca`s
LLVM can usually optimize these away, but especially for things like transmutes of newtypes it's silly to generate the `alloc`+`store`+`load` at all when it's actually a nop at LLVM level.
2023-04-04 18:44:29 -07:00
bors 700938c078 Auto merge of #109808 - jyn514:debuginfo-options, r=michaelwoerister
Extend -Cdebuginfo with new options and named aliases

This is a rebase of https://github.com/rust-lang/rust/pull/83947, along with my best guess at what the new options mean. I tried to follow the LLVM source code to get a better idea but ran into quite a lot of trouble (https://rust-lang.zulipchat.com/#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/go-to-definition.20in.20src.2Fllvm-project.3F). The description for the original PR follows below.

Note that the changes in this PR have already been through FCP: https://github.com/rust-lang/rust/pull/83947#issuecomment-878384979

Closes https://github.com/rust-lang/rust/pull/109311. Helps with https://github.com/rust-lang/rust/pull/104968.
r? `@michaelwoerister` cc `@cuviper`

---

The -Cdebuginfo=1 option was never line tables only and can't be due to backwards compatibility issues. This was clarified and an option for emitting line tables only was added. Additionally an option for emitting line info directives only was added, which is needed for some targets, i.e. nvptx. The debug info options should now behave similarly to clang's debug info options.

Fix https://github.com/rust-lang/rust/issues/60020
Fix https://github.com/rust-lang/rust/issues/64405
2023-04-04 20:01:05 +00:00
Nikita Popov 73f40d4293 Add codegen tests for issues fixed by LLVM 16
Fixes #75978.
Fixes #99960.
Fixes #101048.
Fixes #101082.
Fixes #101814.
Fixes #103132.
Fixes #103327.
2023-04-03 17:02:57 +02:00
The 8472 7a70647f19 llvm 16 finally reconizes some additional vec in-place conversions as noops 2023-04-03 15:29:46 +02:00
Pietro Albini 8f8873e386
remove unknown xcore arch 2023-04-03 10:23:09 +02:00