Skip to content

Commit 7f33242

Browse files
committed
[MemCpyOpt] Add stack move test with ret-only capture (NFC)
From: #125880 (comment)
1 parent 8dd8e5f commit 7f33242

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

llvm/test/Transforms/MemCpyOpt/stack-move.ll

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1715,3 +1715,24 @@ else: ; preds = %then, %entry
17151715

17161716
uselistorder ptr %dest, { 1, 2, 0 }
17171717
}
1718+
1719+
declare ptr @captures_ret_only(ptr captures(ret: address, provenance))
1720+
1721+
define i32 @test_ret_only_capture() {
1722+
; CHECK-LABEL: define i32 @test_ret_only_capture() {
1723+
; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
1724+
; CHECK-NEXT: [[B:%.*]] = alloca i32, align 4
1725+
; CHECK-NEXT: store i32 0, ptr [[A]], align 4
1726+
; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr [[B]], ptr [[A]], i64 4, i1 false)
1727+
; CHECK-NEXT: call void @captures_ret_only(ptr [[B]])
1728+
; CHECK-NEXT: [[V:%.*]] = load i32, ptr [[A]], align 4
1729+
; CHECK-NEXT: ret i32 [[V]]
1730+
;
1731+
%a = alloca i32
1732+
%b = alloca i32
1733+
store i32 0, ptr %a
1734+
call void @llvm.memcpy(ptr %b, ptr %a, i64 4, i1 false)
1735+
call void @captures_ret_only(ptr %b)
1736+
%v = load i32, ptr %a
1737+
ret i32 %v
1738+
}

0 commit comments

Comments
 (0)