about summary refs log tree commit diff
path: root/tests/codegen
AgeCommit message (Collapse)AuthorLines
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-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
2023-05-11Rollup merge of #111375 - rcvalle:rust-cfi-fix-106547, r=bjorn3Michael Goulet-0/+113
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-11Fix testbjorn3-2/+0
2023-05-11Prevent insta-stable no alloc shim supportbjorn3-2/+4
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-11Rollup merge of #111385 - durin42:vec-panik-17, r=AmanieuMatthias Krüger-2/+2
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-10vec-shrink-panik: update expectations to work on LLVM 17Augie Fackler-2/+2
For some reason, the called function is `cleanup` on LLVM 17 instead of `filter`. r? @Amanieu
2023-05-09CFI: Fix SIGILL reached via trait objectsRamon de C Valle-0/+113
Fix #106547 by transforming the concrete self into a reference to a trait object before emitting type metadata identifiers for trait methods.
2023-05-09Rollup merge of #111282 - scottmcm:remove-unneeded-assumes, r=workingjubileeMatthias Krüger-0/+42
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-08Auto merge of #111358 - compiler-errors:rollup-yv27vrp, r=compiler-errorsbors-2/+2
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-08Disable nrvo mir optJakob Degen-18/+20
2023-05-07Fix codegen testGary Guo-2/+2
2023-05-06Remove some `assume`s from slice iterators that don't do anythingScott McMurray-0/+42
2023-05-05`assume` the runtime range of `align_offset`Scott McMurray-0/+78
Found when I saw code with `align_to` having extraneous checks.
2023-05-04Rollup merge of #111009 - scottmcm:ascii-char, r=BurntSushiMatthias Krüger-0/+37
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-03Add the basic `ascii::Char` typeScott McMurray-0/+37
2023-05-03Rollup merge of #110928 - loongarch-rs:tests, r=petrochenkovManish Goregaokar-0/+334
tests: Add tests for LoongArch64
2023-05-03Rollup merge of #105452 - rcvalle:rust-cfi-3, r=bjorn3Manish Goregaokar-171/+680
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-03Add cross-language LLVM CFI support to the Rust compilerRamon de C Valle-171/+680
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-04-30Codegen fewer instructions in `mem::replace`Scott McMurray-41/+40
2023-04-30tests: Add tests for LoongArch64WANG Rui-0/+334
2023-04-29Auto merge of #108106 - the8472:layout-opt, r=wesleywiserbors-21/+12
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-28fix codegen testThe 8472-3/+6