about summary refs log tree commit diff
path: root/tests/codegen/enum
AgeCommit message (Collapse)AuthorLines
2025-07-12Simplify codegen for niche-encoded variant testsScott McMurray-35/+26
2025-07-11More discriminant codegen testsScott McMurray-0/+538
These are from 139729, updated to pass on master.
2025-07-10Rollup merge of #143270 - TimNN:fix-enum-match, r=nikicTrevor Gross-1/+1
tests/codegen/enum/enum-match.rs: accept negative range attribute The test current fails when `rustc` is built with HEAD LLVM: https://buildkite.com/llvm-project/rust-llvm-integrate-prototype/builds/38097/steps/canvas?sid=0197c492-5661-4c42-8ae7-3d789e85c6ca I suspect the change was caused by https://github.com/llvm/llvm-project/commit/545cdca4883552b147a0f1adfac713f76fc22305 ``@rustbot`` label llvm-main
2025-07-07Let `rvalue_creates_operand` return true for *all* `Rvalue::Aggregate`sScott McMurray-9/+6
Inspired by <https://github.com/rust-lang/rust/pull/138759#discussion_r2156375342> where I noticed that we were nearly at this point, plus the comments I was writing in 143410 that reminded me a type-dependent `true` is fine. This PR splits the `OperandRef::builder` logic out to a separate type, with the updates needed to handle SIMD as well. In doing so, that makes the existing `Aggregate` path in `codegen_rvalue_operand` capable of handing SIMD values just fine. As a result, we no longer need to do layout calculations for aggregate result types when running the analysis to determine which things can be SSA in codegen.
2025-07-03Allow all MIR `Aggregate`s to take the operand path (if layout permits)Scott McMurray-0/+129
2025-07-01tests/codegen/enum/enum-match.rs: accept negative range attributeTim Neumann-1/+1
2025-05-28Stabilise `repr128`beetrees-3/+0
2025-04-15Include optional dso_local marker for functions in `enum-match.rs`Christian Poveda-6/+6
2025-04-07Address PR feedbackScott McMurray-0/+16
2025-04-05LLVM18 compatibility fixes in the testsScott McMurray-3/+6
2025-04-05Tell LLVM about impossible niche tagsScott McMurray-19/+437
2025-04-05Update the minimum external LLVM to 19Josh Stone-1/+0
2025-03-12Don't `alloca` just to look at a discriminantScott McMurray-17/+20
Today we're making LLVM do a bunch of extra work for every enum you match on, even trivial stuff like `Option<bool>`. Let's not.
2025-03-06Use `trunc nuw`+`br` for 0/1 branches even in optimized buildsScott McMurray-0/+51
Rather than needing to use `switch` for them to include the `unreachable` arm
2025-02-13Rollup merge of #136895 - maurer:fix-enum-discr, r=nikicJubilee-2/+2
debuginfo: Set bitwidth appropriately in enum variant tags Previously, we unconditionally set the bitwidth to 128-bits, the largest an enum would possibly be. Then, LLVM would cut down the constant by chopping off leading zeroes before emitting the DWARF. LLVM only supported 64-bit enumerators, so this would also have occasionally resulted in truncated data. LLVM added support for 128-bit enumerators in llvm/llvm-project#125578 That patchset trusts the constant to describe how wide the variant tag is, so the high 64-bits of zeros are considered potentially load-bearing. As a result, we went from emitting tags that looked like: DW_AT_discr_value (0xfe) (because `dwarf::BestForm` selected `data1`) to emitting tags that looked like: DW_AT_discr_value (<0x10> fe ff ff ff 00 00 00 00 00 00 00 00 00 00 00 00 ) This makes the `DW_AT_discr_value` encode at the bitwidth of the tag, which: 1. Is probably closer to our intentions in terms of describing the data. 2. Doesn't invoke the 128-bit support which may not be supported by all debuggers / downstream tools. 3. Will result in smaller debug information.
2025-02-12debuginfo: Set bitwidth appropriately in enum variant tagsMatthew Maurer-2/+2
Previously, we unconditionally set the bitwidth to 128-bits, the largest an discrimnator would possibly be. Then, LLVM would cut down the constant by chopping off leading zeroes before emitting the DWARF. LLVM only supported 64-bit descriminators, so this would also have occasionally resulted in truncated data (or an assert) if more than 64-bits were used. LLVM added support for 128-bit enumerators in llvm/llvm-project#125578 That patchset also trusts the constant to describe how wide the variant tag is. As a result, we went from emitting tags that looked like: DW_AT_discr_value (0xfe) (`form1`) to emitting tags that looked like: DW_AT_discr_value (<0x10> fe ff ff ff 00 00 00 00 00 00 00 00 00 00 00 00 ) This makes the `DW_AT_discr_value` encode at the bitwidth of the tag, which: 1. Is probably closer to our intentions in terms of describing the data. 2. Doesn't invoke the 128-bit support which may not be supported by all debuggers / downstream tools. 3. Will result in smaller debug information.
2025-02-11tests/codegen: use -Copt-level=3 instead of -OJubilee Young-5/+5
2024-09-18Update the minimum external LLVM to 18Josh Stone-1/+0
2024-09-14Simplify the canonical clone method to copyDianQK-2/+4
The optimized clone method ends up as the following MIR: ``` _2 = copy ((*_1).0: i32); _3 = copy ((*_1).1: u64); _4 = copy ((*_1).2: [i8; 3]); _0 = Foo { a: move _2, b: move _3, c: move _4 }; ``` We can transform this to: ``` _0 = copy (*_1); ```
2024-08-11Add range attribute to scalar function results and argumentsAndreas Jonson-1/+1
2024-05-31Run rustfmt on `tests/codegen/`.Nicholas Nethercote-12/+21
Except for `simd-intrinsic/`, which has a lot of files containing multiple types like `u8x64` which really are better when hand-formatted. There is a surprising amount of two-space indenting in this directory. Non-trivial changes: - `rustfmt::skip` needed in `debug-column.rs` to preserve meaning of the test. - `rustfmt::skip` used in a few places where hand-formatting read more nicely: `enum/enum-match.rs` - Line number adjustments needed for the expected output of `debug-column.rs` and `coroutine-debug.rs`.
2024-04-30codegen tests: Tolerate `range()` qualifications in enum testsMatthew Maurer-3/+3
Current LLVM can infer range bounds on the i8s involved with these tests, and annotates it. Accept these bounds if present.
2024-04-24Auto merge of #122053 - erikdesjardins:alloca, r=nikicbors-1/+1
Stop using LLVM struct types for alloca The alloca type has no semantic meaning, only the size (and alignment, but we specify it explicitly) matter. Using `[N x i8]` is a more direct way to specify that we want `N` bytes, and avoids relying on LLVM's struct layout. It is likely that a future LLVM version will change to an untyped alloca representation. Split out from #121577. r? `@ghost`
2024-04-22Stabilize generic `NonZero`.Markus Reiter-1/+1
2024-04-11use [N x i8] for alloca typesErik Desjardins-1/+1
2024-04-08Add test case for #119014DianQK-0/+26
2024-04-03Auto merge of #122225 - DianQK:nits-120268, r=cjgillotbors-24/+43
Rename `UninhabitedEnumBranching` to `UnreachableEnumBranching` Per [#120268](https://github.com/rust-lang/rust/pull/120268#discussion_r1517492060), I rename `UninhabitedEnumBranching` to `UnreachableEnumBranching` . I solved some nits to add some comments. I adjusted the workaround restrictions. This should be useful for `a <= b` and `if let Some/Ok(v)`. For enum with few variants, `early-tailduplication` should not cause compile time overhead. r? RalfJung
2024-03-13Update `unreachable_enum_default_branch.rs`DianQK-24/+43
2024-03-11Update test directives for `wasm32-wasip1`Alex Crichton-0/+4
* The WASI targets deal with the `main` symbol a bit differently than native so some `codegen` and `assembly` tests have been ignored. * All `ignore-emscripten` directives have been updated to `ignore-wasm32` to be more clear that all wasm targets are ignored and it's not just Emscripten. * Most `ignore-wasm32-bare` directives are now gone. * Some ignore directives for wasm were switched to `needs-unwind` instead. * Many `ignore-wasm32*` directives are removed as the tests work with WASI as opposed to `wasm32-unknown-unknown`.
2024-03-07Replace the default branch with an unreachable branch If it is the last variantDianQK-0/+24
2024-02-25Use generic `NonZero` in tests.Markus Reiter-10/+7
2024-02-22[AUTO_GENERATED] Migrate compiletest to use `ui_test`-style `//@` directives许杰友 Jieyou Xu (Joe)-17/+17
2023-07-29tests/codegen/enum-* -> enum/enum-*Jubilee Young-0/+381