Skip to content

Commit 519a555

Browse files
committed
add regression test for Redundant memory strores with mut parameters in by-value returns
1 parent 5bbdeaa commit 519a555

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//! Regression test for <https://github.com/rust-lang/rust/issues/149762>:
2+
3+
//@ assembly-output: emit-asm
4+
//@ compile-flags: -Copt-level=3 --target riscv64gc-unknown-linux-gnu
5+
//@ needs-llvm-components: riscv
6+
//@ only-riscv64
7+
8+
pub struct SomeComplexType {
9+
a: u64,
10+
b: u64,
11+
c: u64,
12+
}
13+
14+
// CHECK-LABEL: with_mut_param
15+
#[no_mangle]
16+
pub fn with_mut_param(mut a: SomeComplexType) -> SomeComplexType {
17+
// CHECK: ld a2, 0(a1)
18+
// CHECK-NEXT: ld a3, 8(a1)
19+
// CHECK-NEXT: ld a4, 16(a1)
20+
// CHECK-NEXT: addi a2, a2, 10
21+
// CHECK-NEXT: addi a3, a3, 2
22+
// CHECK-NEXT: sd a2, 0(a1)
23+
// CHECK-NEXT: sd a3, 8(a1)
24+
// CHECK-NEXT: sd a2, 0(a0)
25+
// CHECK-NEXT: sd a3, 8(a0)
26+
// CHECK-NEXT: sd a4, 16(a0)
27+
// CHECK-NEXT: ret
28+
a.a += 10;
29+
a.b += 2;
30+
a
31+
}
32+
33+
fn main() {}

0 commit comments

Comments
 (0)