about summary refs log tree commit diff
path: root/tests/codegen
AgeCommit message (Collapse)AuthorLines
2023-06-27Auto merge of #112516 - erikdesjardins:loop, r=davidtwcobors-0/+12
cg_llvm: use index-based loop in write_operand_repeatedly This should be easier for LLVM to analyze. Fixes #111603 This needs a perf run. [cc](https://github.com/rust-lang/rust/issues/111603#issuecomment-1567531178) `@caojoshua`
2023-06-23Auto merge of #112891 - oli-obk:impl_trait_in_assoc_tys_cleanup, ↵bors-1/+13
r=compiler-errors Various impl trait in assoc tys cleanups r? `@compiler-errors` All commits except for the last are pure refactorings. 274dab5bd658c97886a8987340bf50ae57900c39 allows struct fields to participate in deciding whether a function has an opaque in its signature. best reviewed commit by commit
2023-06-23Auto merge of #112974 - matthiaskrgr:rollup-hnk7ans, r=matthiaskrgrbors-1/+1
Rollup of 8 pull requests Successful merges: - #112616 (Improve tests on targets without unwinding) - #112643 (Always register sized obligation for argument) - #112740 (Add link to rustdoc book search chapter in help popover) - #112810 (Don't ICE on unnormalized struct tail in layout computation) - #112870 (Migrate `item_bounds` to `ty::Clause`) - #112925 (Stop hiding const eval limit in external macros) - #112960 ([tests/rustdoc] Add `@files` command) - #112962 (Fix rustdoc gui tester) r? `@ghost` `@rustbot` modify labels: rollup
2023-06-23Rollup merge of #112616 - ferrocene:pa-more-test-suite-fixes, r=NilstriebMatthias Krüger-1/+1
Improve tests on targets without unwinding This PR makes more miscellaneous changes to tests, to make it work on targets without unwinding support.
2023-06-23tests: be even more permissive on attributes in one testAugie Fackler-17/+17
2023-06-22tests: be more permissive on attributes in one testAugie Fackler-1/+1
2023-06-22Fix a codegen testOli Scherer-1/+13
2023-06-19Auto merge of #112724 - scottmcm:simpler-unchecked-shifts, r=Mark-Simulacrumbors-0/+4
[libs] Simplify `unchecked_{shl,shr}` There's no need for the `const_eval_select` dance here. And while I originally wrote the `.try_into().unwrap_unchecked()` implementation here, it's kinda a mess in MIR -- this new one is substantially simpler, as shown by the old one being above the inlining threshold but the new one being below it in the `mir-opt/inline/unchecked_shifts` tests. We don't need `u32::checked_shl` doing a dance through both `Result` *and* `Option` 🙃
2023-06-16[libs] Simplify `unchecked_{shl,shr}`Scott McMurray-0/+4
There's no need for the `const_eval_select` dance here. And while I originally wrote the `.try_into().unwrap_unchecked()` implementation here, it's kinda a mess in MIR -- this new one is substantially simpler, as shown by the old one being above the inlining threshold but the new one being below it.
2023-06-16Rollup merge of #112474 - ldm0:ldm_enum_debuginfo_128_support, r=compiler-errorsMichael Goulet-2/+29
Support 128-bit enum variant in debuginfo codegen fixes #111600
2023-06-14use indexed loop instead of ptr bumpingThe 8472-8/+0
this seems to produce less IR
2023-06-14update codegent test to be independent of panic strategyPietro Albini-1/+1
2023-06-12add codegen test for slice::Iter::foldThe 8472-0/+14
2023-06-11cg_llvm: use index-based loop in write_operand_repeatedlyErik Desjardins-0/+12
This is easier for LLVM to analyze.
2023-06-10Add testldm0-0/+27
2023-06-10Fix codegen testsldm0-2/+2
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.