about summary refs log tree commit diff
path: root/tests/codegen
AgeCommit message (Collapse)AuthorLines
2024-01-16Add unstable `-Z direct-access-external-data` cmdline flag for `rustc`WANG Rui-0/+21
The new flag has been described in the Major Change Proposal at https://github.com/rust-lang/compiler-team/issues/707
2024-01-15Auto merge of #119878 - scottmcm:inline-always-unwrap, r=workingjubileebors-0/+26
Tune the inlinability of `unwrap` Fixes #115463 cc `@thomcc` This tweaks `unwrap` on ~~`Option` &~~ `Result` to be two parts: - `#[inline(always)]` for checking the discriminant - `#[cold]` for actually panicking The idea here is that checking the discriminant on a `Result` ~~or `Option`~~ should always be trivial enough to be worth inlining, even in `opt-level=z`, especially compared to passing it to a function. As seen in the issue and codegen test, this will hopefully help particularly for things like `.try_into().unwrap()`s that are actually infallible, but in a way that's only visible with the inlining. EDIT: I've restricted this to `Result` to avoid combining effects
2024-01-14Split out `option::unwrap_failed` like we have `result::unwrap_failed`Scott McMurray-2/+2
...and like `option::expect_failed`
2024-01-12Auto merge of #119452 - ↵bors-0/+83
AngelicosPhosphoros:make_nonzeroint_get_assume_nonzero, r=scottmcm Add assume into `NonZeroIntX::get` LLVM currently don't support range metadata for function arguments so it fails to optimize non zero integers using their invariant if they are provided using by-value function arguments. Related to https://github.com/rust-lang/rust/issues/119422 Related to https://github.com/llvm/llvm-project/issues/76628 Related to https://github.com/rust-lang/rust/issues/49572
2024-01-12Tune the inlinability of `Result::unwrap`Scott McMurray-0/+26
2024-01-07mark vec::IntoIter pointers as `!nonnull`The 8472-0/+46
2024-01-06Add assume into `NonZeroIntX::get`AngelicosPhosphoros-0/+83
LLVM currently don't support range metadata for function arguments so it fails to optimize non zero integers using their invariant if they are provided using by-value function arguments. Related to https://github.com/rust-lang/rust/issues/119422 Related to https://github.com/llvm/llvm-project/issues/76628 Related to https://github.com/rust-lang/rust/issues/49572
2024-01-05Auto merge of #118991 - nikic:scalar-pair, r=nagisabors-34/+33
Separate immediate and in-memory ScalarPair representation Currently, we assume that ScalarPair is always represented using a two-element struct, both as an immediate value and when stored in memory. This currently works fairly well, but runs into problems with https://github.com/rust-lang/rust/pull/116672, where a ScalarPair involving an i128 type can no longer be represented as a two-element struct in memory. For example, the tuple `(i32, i128)` needs to be represented in-memory as `{ i32, [3 x i32], i128 }` to satisfy alignment requirements. Using `{ i32, i128 }` instead will result in the second element being stored at the wrong offset (prior to LLVM 18). Resolve this issue by no longer requiring that the immediate and in-memory type for ScalarPair are the same. The in-memory type will now look the same as for normal struct types (and will include padding filler and similar), while the immediate type stays a simple two-element struct type. This also means that booleans in immediate ScalarPair are now represented as i1 rather than i8, just like we do everywhere else. The core change here is to llvm_type (which now treats ScalarPair as a normal struct) and immediate_llvm_type (which returns the two-element struct that llvm_type used to produce). The rest is fixing things up to no longer assume these are the same. In particular, this switches places that try to get pointers to the ScalarPair elements to use byte-geps instead of struct-geps.
2024-01-05Make test compatible with 32-bit as wellNikita Popov-1/+1
2024-01-04Rollup merge of #119555 - Kobzol:maybeuninit-rvo-codegen-test, r=nikicMatthias Krüger-0/+33
Add codegen test for RVO on MaybeUninit Codegen test for https://github.com/rust-lang/rust/issues/90595. Currently, this only works with `-Cpanic=abort`, but hopefully in the [future](https://www.npopov.com/2024/01/01/This-year-in-LLVM-2023.html#writable-and-dead_on_unwind) it should also work in the presence of panics. r? ``@nikic``
2024-01-03Add codegen test for RVO on MaybeUninitJakub Beránek-0/+33
Currently, this only works with `-Cpanic=abort`.
2024-01-03Rollup merge of #119523 - maurer:fix-sparc-llvm-18, r=nikicLeón Orell Valerian Liehr-2/+2
llvm: Allow `noundef` in codegen tests LLVM 18 will automatically infer `noundef` in some situations. Adjust codegen tests to accept this. See llvm/llvm-project#76553 for why `noundef` is being generated now. ``@rustbot`` label:+llvm-main
2024-01-02llvm: Allow `noundef` in codegen testsMatthew Maurer-2/+2
LLVM 18 will automatically infer `noundef` in some situations. Adjust codegen tests to accept this. See llvm/llvm-project#76553 for why `noundef` is being generated now.
2024-01-02Address review commentsNikita Popov-1/+1
2023-12-24Revert codegen test change.Camille GILLOT-0/+2
2023-12-24Replace legacy ConstProp by GVN.Camille GILLOT-1/+1
2023-12-24Enable GVN by default.Camille GILLOT-2/+0
2023-12-21tests: fix overaligned-constant to not over-specify getelementptr instrAugie Fackler-1/+1
On LLVM 18 we get slightly different arguments here, so it's easier to just regex those away. The important details are all still asserted as I understand things. Fixes #119193. @rustbot label: +llvm-main
2023-12-21Auto merge of #119056 - cjgillot:codegen-overalign, r=wesleywiserbors-0/+36
Tolerate overaligned MIR constants for codegen. Fixes https://github.com/rust-lang/rust/issues/117761 cc `@saethlin`
2023-12-20Auto merge of #106790 - the8472:rawvec-niche, r=scottmcmbors-8/+20
add more niches to rawvec Previously RawVec only had a single niche in its `NonNull` pointer. With this change it now has `isize::MAX` niches since half the value-space of the capacity field is never needed, we can't have a capacity larger than isize::MAX.
2023-12-17Fortify test.Camille GILLOT-4/+9
2023-12-17Tolerate overaligned MIR constants for codegen.Camille GILLOT-0/+31
2023-12-15Separate immediate and in-memory ScalarPair representationNikita Popov-33/+32
Currently, we assume that ScalarPair is always represented using a two-element struct, both as an immediate value and when stored in memory. This currently works fairly well, but runs into problems with https://github.com/rust-lang/rust/pull/116672, where a ScalarPair involving an i128 type can no longer be represented as a two-element struct in memory. For example, the tuple `(i32, i128)` needs to be represented in-memory as `{ i32, [3 x i32], i128 }` to satisfy alignment requirement. Using `{ i32, i128 }` instead will result in the second element being stored at the wrong offset (prior to LLVM 18). Resolve this issue by no longer requiring that the immediate and in-memory type for ScalarPair are the same. The in-memory type will now look the same as for normal struct types (and will include padding filler and similar), while the immediate type stays a simple two-element struct type. This also means that booleans in immediate ScalarPair are now represented as i1 rather than i8, just like we do everywhere else. The core change here is to llvm_type (which now treats ScalarPair as a normal struct) and immediate_llvm_type (which returns the two-element struct that llvm_type used to produce). The rest is fixing things up to no longer assume these are the same. In particular, this switches places that try to get pointers to the ScalarPair elements to use byte-geps instead of struct-geps.
2023-12-15Adapt debug-accessibility tests for msvc-style enumsWesley Wiser-4/+12
2023-12-15codegen_llvm: set DW_AT_accessibilityDavid Wood-0/+221
Sets the accessibility of types and fields in DWARF using `DW_AT_accessibility` attribute. `DW_AT_accessibility` (public/protected/private) isn't exactly right for Rust, but neither is `DW_AT_visibility` (local/exported/qualified), and there's no way to set `DW_AT_visbility` in LLVM's API. Signed-off-by: David Wood <david@davidtw.co>
2023-12-14Auto merge of #118417 - anforowicz:default-hidden-visibility, r=TaKO8Kibors-0/+31
Add unstable `-Zdefault-hidden-visibility` cmdline flag for `rustc`. The new flag has been described in the Major Change Proposal at https://github.com/rust-lang/compiler-team/issues/656
2023-12-14Auto merge of #118491 - cuviper:aarch64-stack-probes, r=wesleywiserbors-1/+3
Enable stack probes on aarch64 for LLVM 18 I tested this on `aarch64-unknown-linux-gnu` with LLVM main (~18). cc #77071, to be closed once we upgrade our LLVM submodule.
2023-12-13Add unstable `-Zdefault-hidden-visibility` cmdline flag for `rustc`.Lukasz Anforowicz-0/+31
The new flag has been described in the Major Change Proposal at https://github.com/rust-lang/compiler-team/issues/656
2023-12-12Fix alignment passed down to LLVM for simd_masked_loadJakub Okoński-2/+2
2023-12-11add more niches to rawvecThe 8472-8/+20
2023-12-09Add simd_masked_{load,store} platform-intrinsicsJakub Okoński-0/+66
This maps to the LLVM intrinsics: llvm.masked.load and llvm.masked.store
2023-12-07Enable stack probes on aarch64 for LLVM 18Josh Stone-1/+3
2023-12-07CFI: Add char to CFI integer normalizationRamon de C Valle-57/+20
Adds char to CFI integer normalization to conform to #118032 for cross-language CFI support.
2023-12-04use `assume(idx < self.len())` in `[T]::get_unchecked`bendn-0/+13
2023-12-02Auto merge of #118077 - calebzulawski:sync-portable-simd-2023-11-19, ↵bors-1/+1
r=workingjubilee Portable SIMD subtree update Syncs nightly to the latest changes from rust-lang/portable-simd r? `@rust-lang/libs`
2023-11-30Auto merge of #116892 - ojeda:rethunk, r=wesleywiserbors-0/+28
Add `-Zfunction-return={keep,thunk-extern}` option This is intended to be used for Linux kernel RETHUNK builds. With this commit (optionally backported to Rust 1.73.0), plus a patched Linux kernel to pass the flag, I get a RETHUNK build with Rust enabled that is `objtool`-warning-free and is able to boot in QEMU and load a sample Rust kernel module. Issue: https://github.com/rust-lang/rust/issues/116853.
2023-11-30Add `-Zfunction-return={keep,thunk-extern}` optionMiguel Ojeda-0/+28
This is intended to be used for Linux kernel RETHUNK builds. With this commit (optionally backported to Rust 1.73.0), plus a patched Linux kernel to pass the flag, I get a RETHUNK build with Rust enabled that is `objtool`-warning-free and is able to boot in QEMU and load a sample Rust kernel module. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2023-11-30Auto merge of #118036 - DianQK:thinlto-tests, r=tmiaskobors-0/+7
Add thinlto support to codegen, assembly and coverage tests Using `--emit=llvm-ir` with thinlto usually result in multiple IR files. Resolve test case failure issue reported in #113923.
2023-11-30Add thinlto support to codegen, assembly and coverage testsDianQK-0/+7
2023-11-28update test for new LLVM 18 codegenKrasimir Georgiev-1/+1
LLVM at HEAD now emits `or disjoint`: https://buildkite.com/llvm-project/rust-llvm-integrate-prototype/builds/24076#018c1596-8153-488e-b622-951266a02f6c/741-774
2023-11-27Auto merge of #117947 - Dirbaio:drop-llvm-15, r=cuviperbors-38/+0
Update the minimum external LLVM to 16. With this change, we'll have stable support for LLVM 16 and 17. For reference, the previous increase to LLVM 15 was #114148 [Relevant zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/riscv.20forced-atomics)
2023-11-26Update std::simd usage and test outputsCaleb Zulawski-1/+1
2023-11-25Remove an unneeded helper from the tuple library codeScott McMurray-6/+8
2023-11-21convert ehcont-guard to an unstable optionArlie Davis-1/+1
2023-11-21Add support for generating the EHCont sectionArlie Davis-0/+20
In the future Windows will enable Control-flow Enforcement Technology (CET aka Shadow Stacks). To protect the path where the context is updated during exception handling, the binary is required to enumerate valid unwind entrypoints in a dedicated section which is validated when the context is being set during exception handling. The required support for EHCONT has already been merged into LLVM, long ago. This change adds the Rust codegen option to enable it. Reference: * https://reviews.llvm.org/D40223 This also adds a new `ehcont-guard` option to the bootstrap config which enables EHCont Guard when building std.
2023-11-21Update the minimum external LLVM to 16.Dario Nieuwenhuis-38/+0
2023-11-15Auto merge of #116555 - paulmenage:llvm-module-flag, r=wesleywiserbors-0/+7
Add -Z llvm_module_flag Allow adding values to the `!llvm.module.flags` metadata for a generated module. The syntax is `-Z llvm_module_flag=<name>:<type>:<value>:<behavior>` Currently only u32 values are supported but the type is required to be specified for forward compatibility. The `behavior` element must match one of the named LLVM metadata behaviors.viors. This flag is expected to be perma-unstable.
2023-11-13tests: update check for inferred nneg on zextAugie Fackler-2/+2
This was broken by upstream llvm/llvm-project@dc6d0773960c664eee12a1ed871fad5c81a20a12. It's easy enough to use a regex match to support both, so we do that. r? @nikic @rustbot label: +llvm-main
2023-11-11Add -Z llvm_module_flagPaul Menage-0/+7
Allow adding values to the `!llvm.module.flags` metadata for a generated module. The syntax is `-Z llvm_module_flag=<name>:<type>:<value>:<behavior>` Currently only u32 values are supported but the type is required to be specified for forward compatibility. The `behavior` element must match one of the named LLVM metadata behaviors.viors. This flag is expected to be perma-unstable.
2023-11-09Emit #[inline] on derive(Debug)Ben Kimock-2/+7