diff options
| author | Scott McMurray <scottmcm@users.noreply.github.com> | 2025-07-19 20:49:52 -0700 |
|---|---|---|
| committer | Scott McMurray <scottmcm@users.noreply.github.com> | 2025-07-19 20:50:02 -0700 |
| commit | 4b8f869c638e6d5090420ff46bd14e7b7d909690 (patch) | |
| tree | 79ea7edbddbc90f2a3fc0d54332da41d7c6061f1 /tests/codegen | |
| parent | 0586c63e070981af7df53e2f778d3e50293d8103 (diff) | |
| download | rust-4b8f869c638e6d5090420ff46bd14e7b7d909690.tar.gz rust-4b8f869c638e6d5090420ff46bd14e7b7d909690.zip | |
Split repeat-operand codegen test
Looks like the output it's looking for can be in different orders, so separate tests will fix that.
Diffstat (limited to 'tests/codegen')
| -rw-r--r-- | tests/codegen/repeat-operand-zero-len.rs (renamed from tests/codegen/repeat-operand.rs) | 11 | ||||
| -rw-r--r-- | tests/codegen/repeat-operand-zst-elem.rs | 28 |
2 files changed, 28 insertions, 11 deletions
diff --git a/tests/codegen/repeat-operand.rs b/tests/codegen/repeat-operand-zero-len.rs index 6464b35ddca..b4cec42a07c 100644 --- a/tests/codegen/repeat-operand.rs +++ b/tests/codegen/repeat-operand-zero-len.rs @@ -11,10 +11,6 @@ #[repr(transparent)] pub struct Wrapper<T, const N: usize>([T; N]); -// CHECK-LABEL: define {{.+}}do_repeat{{.+}}() -// CHECK-NEXT: start: -// CHECK-NOT: alloca -// CHECK-NEXT: ret void // CHECK-LABEL: define {{.+}}do_repeat{{.+}}(i32 noundef %x) // CHECK-NEXT: start: // CHECK-NOT: alloca @@ -30,10 +26,3 @@ pub fn trigger_repeat_zero_len() -> Wrapper<u32, 0> { // CHECK: call void {{.+}}do_repeat{{.+}}(i32 noundef 4) do_repeat(4) } - -// CHECK-LABEL: @trigger_repeat_zst -#[no_mangle] -pub fn trigger_repeat_zst() -> Wrapper<(), 8> { - // CHECK: call void {{.+}}do_repeat{{.+}}() - do_repeat(()) -} diff --git a/tests/codegen/repeat-operand-zst-elem.rs b/tests/codegen/repeat-operand-zst-elem.rs new file mode 100644 index 00000000000..c3637759afa --- /dev/null +++ b/tests/codegen/repeat-operand-zst-elem.rs @@ -0,0 +1,28 @@ +//@ compile-flags: -Copt-level=1 -Cno-prepopulate-passes + +// This test is here to hit the `Rvalue::Repeat` case in `codegen_rvalue_operand`. +// It only applies when the resulting array is a ZST, so the test is written in +// such a way as to keep MIR optimizations from seeing that fact and removing +// the local and statement altogether. (At the time of writing, no other codegen +// test hit that code path, nor did a stage 2 build of the compiler.) + +#![crate_type = "lib"] + +#[repr(transparent)] +pub struct Wrapper<T, const N: usize>([T; N]); + +// CHECK-LABEL: define {{.+}}do_repeat{{.+}}() +// CHECK-NEXT: start: +// CHECK-NOT: alloca +// CHECK-NEXT: ret void +#[inline(never)] +pub fn do_repeat<T: Copy, const N: usize>(x: T) -> Wrapper<T, N> { + Wrapper([x; N]) +} + +// CHECK-LABEL: @trigger_repeat_zst_elem +#[no_mangle] +pub fn trigger_repeat_zst_elem() -> Wrapper<(), 8> { + // CHECK: call void {{.+}}do_repeat{{.+}}() + do_repeat(()) +} |
