Skip to content

Commit 4b8f869

Browse files
committed
Split repeat-operand codegen test
Looks like the output it's looking for can be in different orders, so separate tests will fix that.
1 parent 0586c63 commit 4b8f869

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

tests/codegen/repeat-operand.rs renamed to tests/codegen/repeat-operand-zero-len.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
#[repr(transparent)]
1212
pub struct Wrapper<T, const N: usize>([T; N]);
1313

14-
// CHECK-LABEL: define {{.+}}do_repeat{{.+}}()
15-
// CHECK-NEXT: start:
16-
// CHECK-NOT: alloca
17-
// CHECK-NEXT: ret void
1814
// CHECK-LABEL: define {{.+}}do_repeat{{.+}}(i32 noundef %x)
1915
// CHECK-NEXT: start:
2016
// CHECK-NOT: alloca
@@ -30,10 +26,3 @@ pub fn trigger_repeat_zero_len() -> Wrapper<u32, 0> {
3026
// CHECK: call void {{.+}}do_repeat{{.+}}(i32 noundef 4)
3127
do_repeat(4)
3228
}
33-
34-
// CHECK-LABEL: @trigger_repeat_zst
35-
#[no_mangle]
36-
pub fn trigger_repeat_zst() -> Wrapper<(), 8> {
37-
// CHECK: call void {{.+}}do_repeat{{.+}}()
38-
do_repeat(())
39-
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//@ compile-flags: -Copt-level=1 -Cno-prepopulate-passes
2+
3+
// This test is here to hit the `Rvalue::Repeat` case in `codegen_rvalue_operand`.
4+
// It only applies when the resulting array is a ZST, so the test is written in
5+
// such a way as to keep MIR optimizations from seeing that fact and removing
6+
// the local and statement altogether. (At the time of writing, no other codegen
7+
// test hit that code path, nor did a stage 2 build of the compiler.)
8+
9+
#![crate_type = "lib"]
10+
11+
#[repr(transparent)]
12+
pub struct Wrapper<T, const N: usize>([T; N]);
13+
14+
// CHECK-LABEL: define {{.+}}do_repeat{{.+}}()
15+
// CHECK-NEXT: start:
16+
// CHECK-NOT: alloca
17+
// CHECK-NEXT: ret void
18+
#[inline(never)]
19+
pub fn do_repeat<T: Copy, const N: usize>(x: T) -> Wrapper<T, N> {
20+
Wrapper([x; N])
21+
}
22+
23+
// CHECK-LABEL: @trigger_repeat_zst_elem
24+
#[no_mangle]
25+
pub fn trigger_repeat_zst_elem() -> Wrapper<(), 8> {
26+
// CHECK: call void {{.+}}do_repeat{{.+}}()
27+
do_repeat(())
28+
}

0 commit comments

Comments
 (0)