about summary refs log tree commit diff
path: root/tests/codegen
AgeCommit message (Collapse)AuthorLines
2023-06-04Use `load`-`store` instead of `memcpy` for short integer arraysScott McMurray-15/+65
2023-06-04Add a codegen test for manually swapping a small `Copy` typeScott McMurray-0/+20
To confirm we're not just helping `mem::swap`
2023-06-03Rollup merge of #111878 - ferrocene:pa-codegen-tests, r=Mark-SimulacrumMatthias Krüger-55/+64
Fix codegen test suite for bare-metal-like targets For Ferrocene I needed to run the test suite for custom target with no unwinding and static relocation. Running the tests uncovered ~20 failures due to the test suite not accounting for these options. This PR fixes them by: * Fixing `CHECK`s to account for functions having extra LLVM IR attributes (in this case `nounwind`). * Fixing `CHECK`s to account for the `dso_local` LLVM IR modifier, which is [added to every item when relocation is static](https://github.com/rust-lang/rust/blob/f3d597b31c0f101a02c230798afa31a36bdacbc6/compiler/rustc_codegen_llvm/src/mono_item.rs#L139-L142). * Fixing `CHECK`s to account for missing `uwtables` attributes. * Added the `needs-unwind` attributes for tests that are designed to check unwinding. There is no part of Rust CI that checks this unfortunately, and testing whether the PR works locally is kinda hard because you need a target with std enabled but no unwinding and static relocations. Still, this works in my local testing, and if future PRs accidentally break this Ferrocene will take care of sending followup PRs.
2023-06-02Rollup merge of #112182 - rcvalle:rust-cfi-fix-111185, r=compiler-errorsMatthias Krüger-3/+3
CFI: Fix cfi with repr(transparent): transform_ty: unexpected Alias(Proj Fixes https://github.com/rust-lang/rust/issues/111185 by normalizing ty::Alias before encoding.
2023-06-01CFI: Fix cfi with repr(transparent): transform_ty: unexpected Alias(ProjRamon de C Valle-3/+3
Fixes #111185 by normalizing ty::Alias before encoding.
2023-06-01Auto merge of #112002 - saethlin:enable-sroa, r=oli-obk,scottmcmbors-3/+4
Enable ScalarReplacementOfAggregates in optimized builds Like MatchBranchSimplification, this pass is known to produce significant runtime improvements in Cranelift artifacts, and I believe based on the perf runs here that the primary effect of this pass is to empower MatchBranchSimplification. ScalarReplacementOfAggregates on its own has little effect on anything, but when this was rebased up to include https://github.com/rust-lang/rust/pull/112001 we started seeing significant and majority-positive results. Based on the fact that we see most of the regressions in debug builds (https://github.com/rust-lang/rust/pull/112002#issuecomment-1566270144) and some rather significant ones in cycles and wall time, I'm only enabling this in optimized builds at the moment.
2023-05-31Add a distinct `OperandValue::ZeroSized` variant for ZSTsScott McMurray-4/+71
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.
2023-05-31Enable ScalarReplacementOfAggregatesBen Kimock-3/+4
2023-05-31Auto merge of #111913 - oli-obk:valtrees2, r=lcnrbors-0/+2
Only rewrite valtree-constants to patterns and keep other constants opaque Now that we can reliably fall back to comparing constants with `PartialEq::eq` to the match scrutinee, we can 1. eagerly try to convert constants to valtrees 2. then deeply convert the valtree to a pattern 3. if the to-valtree conversion failed, create an "opaque constant" pattern. This PR specifically avoids any behavioral changes or major cleanups. What we can now do as follow ups is * move the two remaining call sites to `destructure_mir_constant` off that query * make valtree to pattern conversion infallible * this needs to be done after careful analysis of the effects. There may be user visible changes from that. based on https://github.com/rust-lang/rust/pull/111768
2023-05-31Explain the reason for why a test existsOli Scherer-0/+2
2023-05-31Rollup merge of #112096 - workingjubilee:array-unzip, r=scottmcmMatthias Krüger-15/+3
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-30Test from_fn autovectorizesScottMcMurray-0/+10
2023-05-30Auto merge of #111768 - oli-obk:pair_const_llvm, r=cjgillotbors-0/+8
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-30Remove array_zipJubilee Young-22/+0
`[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-26Add SafeStack support to rustcWesley Wiser-0/+11
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-26Stop creating intermediate places just to immediate convert them to operandsOli Scherer-3/+1
2023-05-26Add regression testOli Scherer-0/+10
2023-05-25Auto merge of #86844 - bjorn3:global_alloc_improvements, r=pnkfelixbors-4/+4
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-23Auto merge of #111882 - matthiaskrgr:rollup-1xyv5mq, r=matthiaskrgrbors-9/+71
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-23Rollup merge of #111851 - rcvalle:rust-cfi-fix-111515, r=bjorn3Matthias Krüger-9/+71
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-23CFI: Fix encode_region: unexpected ReEarlyBound(0, 'a)Ramon de C Valle-9/+71
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-23Auto merge of #107294 - JamieCunliffe:neon-fp, r=Amanieubors-0/+29
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-23codegen: add needs-unwind to tests that require itPietro Albini-0/+9
2023-05-23codegen: do not require the uwtables attributePietro Albini-1/+1
The attribute is not emitted on targets without unwinding tables.
2023-05-23codegen: allow the dso_local attributePietro Albini-50/+50
The attribute is injected into most items when static relocation is enabled in a target.
2023-05-23codegen: allow extra attributes to functions when panic=abortPietro Albini-4/+4
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-23Auto merge of #111869 - Dylan-DPC:rollup-9pydw08, r=Dylan-DPCbors-9/+3
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-23Rollup merge of #111579 - scottmcm:enum-as-signed, r=oli-obkDylan DPC-9/+3
Also assume wrap-around discriminants in `as` MIR building Resolves this FIXME: https://github.com/rust-lang/rust/blob/8d18c32b61476ed16dd15074e71be3970368d6d7/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs#L231 r? `@oli-obk`
2023-05-23Auto merge of #111807 - erikdesjardins:noalias, r=oli-obkbors-1/+42
[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-22drop-in-place-noalias test: needs -O to ensure attributes are added on nopt ↵Erik Desjardins-1/+1
builders
2023-05-22Auto merge of #111634 - marc0246:arc-new-uninit-bloat, r=thomccbors-0/+28
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-22Create a structure to define the features from to_llvm_features.Jamie Cunliffe-5/+5
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-22Make v8a match optional in the test feature list.Jamie Cunliffe-4/+8
2023-05-22Only disable folded features when it makes sense.Jamie Cunliffe-0/+25
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-21Auto merge of #111697 - rcvalle:rust-cfi-fix-111510, r=bjorn3bors-48/+137
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-20make noalias-box-off filecheck more preciseErik Desjardins-2/+5
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-20ensure !Unpin types do not get noaliasErik Desjardins-19/+23
2023-05-20Apply `noalias`, `nonnull`, `dereferenceable`, and `align` attributes ↵Patrick Walton-1/+1
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-20Fix noalias box testPatrick Walton-1/+1
2023-05-20[rustc_ty_utils] Add the LLVM `noalias` parameter attribute to ↵Patrick Walton-0/+34
`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-18Also assume wrap-around discriminants in `as` MIR buildingScott McMurray-9/+3
Resolves this FIXME: https://github.com/rust-lang/rust/blob/8d18c32b61476ed16dd15074e71be3970368d6d7/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs#L231
2023-05-17CFI: Fix encode_ty: unexpected Param(B/#1)Ramon de C Valle-48/+137
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-16Auto merge of #111556 - cjgillot:copy-prop-nrvo, r=oli-obkbors-9/+6
Merge return place with other locals in CopyProp. This reintroduces a limited form of NRVO. r? wg-mir-opt
2023-05-16Fix duplicate `arcinner_layout_for_value_layout` callsmarc0246-0/+28
2023-05-15Rollup merge of #111525 - scottmcm:slice-position-tweak, r=Mark-SimulacrumMatthias Krüger-7/+27
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-14Merge return place with other locals in CopyProp.Camille GILLOT-9/+6
2023-05-14Auto merge of #111517 - lukas-code:addr-of-mutate, r=tmiaskobors-0/+34
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-12Stop checking for the absense of something that doesn't existScott McMurray-7/+27
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-12Remove useless `assume`s from `slice::iter(_mut)`Scott McMurray-0/+35
2023-05-13allow mutating function args through `&raw const`Lukas Markeffsky-0/+34