Skip to content

Commit a8c6fb4

Browse files
committed
[MemCpyOpt] Fix lifetime marker sizes in tests (NFC)
As pointed out in #143782, these tests were specifying the size in bits instead of bytes. In order to preserve the intent of the tests, add a use of %src, which prevents stack-move optimization. These are supposed to test the handling of scoped alias metadata in call slot optimization.
1 parent 3e5d50f commit a8c6fb4

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

llvm/test/Analysis/ScopedNoAliasAA/alias-scope-merging.ll

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
; RUN: opt < %s -S -passes=memcpyopt | FileCheck --match-full-lines %s
22

3+
declare void @use(ptr)
4+
35
; Alias scopes are merged by taking the intersection of domains, then the union of the scopes within those domains
46
define i8 @test(i8 %input) {
57
%tmp = alloca i8
68
%dst = alloca i8
79
%src = alloca i8
810
; CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 8 %dst, ptr align 8 %src, i64 1, i1 false), !alias.scope ![[SCOPE:[0-9]+]]
9-
call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %src), !noalias !4
11+
call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %src), !noalias !4
1012
store i8 %input, ptr %src
1113
call void @llvm.memcpy.p0.p0.i64(ptr align 8 %tmp, ptr align 8 %src, i64 1, i1 false), !alias.scope !0
12-
call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %src), !noalias !4
14+
call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %src), !noalias !4
1315
call void @llvm.memcpy.p0.p0.i64(ptr align 8 %dst, ptr align 8 %tmp, i64 1, i1 false), !alias.scope !4
1416
%ret_value = load i8, ptr %dst
17+
call void @use(ptr %src)
1518
ret i8 %ret_value
1619
}
1720

llvm/test/Transforms/MemCpyOpt/callslot_badaa.ll

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
; RUN: opt < %s -S -passes=memcpyopt | FileCheck --match-full-lines %s
22

3+
declare void @use(ptr)
4+
35
; Make sure callslot optimization merges alias.scope metadata correctly when it merges instructions.
46
; Merging here naively generates:
57
; call void @llvm.memcpy.p0.p0.i64(ptr align 8 %dst, ptr align 8 %src, i64 1, i1 false), !alias.scope !3
6-
; call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %src), !noalias !0
8+
; call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %src), !noalias !0
79
; ...
810
; !0 = !{!1}
911
; !1 = distinct !{!1, !2, !"callee1: %a"}
@@ -18,12 +20,13 @@ define i8 @test(i8 %input) {
1820
%src = alloca i8
1921
; NOTE: we're matching the full line and looking for the lack of !alias.scope here
2022
; CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 8 %dst, ptr align 8 %src, i64 1, i1 false)
21-
call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %src), !noalias !3
23+
call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %src), !noalias !3
2224
store i8 %input, ptr %src
2325
call void @llvm.memcpy.p0.p0.i64(ptr align 8 %tmp, ptr align 8 %src, i64 1, i1 false), !alias.scope !0
24-
call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %src), !noalias !3
26+
call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %src), !noalias !3
2527
call void @llvm.memcpy.p0.p0.i64(ptr align 8 %dst, ptr align 8 %tmp, i64 1, i1 false), !alias.scope !3
2628
%ret_value = load i8, ptr %dst
29+
call void @use(ptr %src)
2730
ret i8 %ret_value
2831
}
2932

0 commit comments

Comments
 (0)