[llvm] 24cd933 - [MemCpyOpt] Add test for call slot opt with ret-only capture (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 20 06:56:24 PST 2025
Author: Nikita Popov
Date: 2025-02-20T15:55:50+01:00
New Revision: 24cd933d02b820f73c4ee6e4277ed1b6e95b570a
URL: https://github.com/llvm/llvm-project/commit/24cd933d02b820f73c4ee6e4277ed1b6e95b570a
DIFF: https://github.com/llvm/llvm-project/commit/24cd933d02b820f73c4ee6e4277ed1b6e95b570a.diff
LOG: [MemCpyOpt] Add test for call slot opt with ret-only capture (NFC)
From: https://github.com/llvm/llvm-project/pull/125880#issuecomment-2671725079
Added:
Modified:
llvm/test/Transforms/MemCpyOpt/memcpy.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/MemCpyOpt/memcpy.ll b/llvm/test/Transforms/MemCpyOpt/memcpy.ll
index 061b85357b771..89d8eb1ee6711 100644
--- a/llvm/test/Transforms/MemCpyOpt/memcpy.ll
+++ b/llvm/test/Transforms/MemCpyOpt/memcpy.ll
@@ -907,6 +907,23 @@ define void @memcpy_immut_escape_after(ptr align 4 noalias %val) {
ret void
}
+declare void @two_args(ptr, ptr)
+
+; Should not perform call slot optimization: The function accepts the
+; destination as an argument and may read/write it.
+define void @test(ptr noalias writable dereferenceable(4) %p) {
+; CHECK-LABEL: @test(
+; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
+; CHECK-NEXT: [[RET:%.*]] = call ptr @two_args(ptr [[A]], ptr captures(ret: address, provenance) [[P:%.*]]) #[[ATTR2]]
+; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 [[P]], ptr [[A]], i64 4, i1 false)
+; CHECK-NEXT: ret void
+;
+ %a = alloca i32
+ %ret = call ptr @two_args(ptr %a, ptr captures(ret: address, provenance) %p) nounwind
+ call void @llvm.memcpy(ptr align 4 %p, ptr %a, i64 4, i1 false)
+ ret void
+}
+
!0 = !{!0}
!1 = !{!1, !0}
!2 = !{!1}
More information about the llvm-commits
mailing list