1
1
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2
2
; RUN: opt -S -passes=memcpyopt < %s -verify-memoryssa | FileCheck %s
3
+ ; RUN: opt -S -passes="tailcallelim,memcpyopt" < %s -verify-memoryssa | FileCheck %s
3
4
4
5
; PR40118: BasicAA didn't realize that stackrestore ends the lifetime of
5
6
; unescaped dynamic allocas, such as those that might come from inalloca.
@@ -23,7 +24,7 @@ define i32 @test_norestore(i32 %n) {
23
24
; CHECK-NEXT: store i8 0, ptr [[P10]], align 1
24
25
; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr [[TMPMEM]], ptr [[P]], i32 10, i1 false)
25
26
; CHECK-NEXT: call void @external()
26
- ; CHECK-NEXT: [[HEAP:%.*]] = call ptr @malloc(i32 9)
27
+ ; CHECK-NEXT: [[HEAP:%.*]] = tail call ptr @malloc(i32 9)
27
28
; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr [[HEAP]], ptr align 1 @str, i32 9, i1 false)
28
29
; CHECK-NEXT: call void @useit(ptr [[HEAP]])
29
30
; CHECK-NEXT: ret i32 0
@@ -40,7 +41,7 @@ define i32 @test_norestore(i32 %n) {
40
41
41
42
call void @llvm.memcpy.p0.p0.i32 (ptr %tmpmem , ptr %p , i32 10 , i1 false )
42
43
call void @external ()
43
- %heap = call ptr @malloc (i32 9 )
44
+ %heap = tail call ptr @malloc (i32 9 )
44
45
call void @llvm.memcpy.p0.p0.i32 (ptr %heap , ptr %tmpmem , i32 9 , i1 false )
45
46
call void @useit (ptr %heap )
46
47
ret i32 0
@@ -58,7 +59,7 @@ define i32 @test_stackrestore() {
58
59
; CHECK-NEXT: store i8 0, ptr [[P10]], align 1
59
60
; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr [[TMPMEM]], ptr [[ARGMEM]], i32 10, i1 false)
60
61
; CHECK-NEXT: call void @llvm.stackrestore.p0(ptr [[INALLOCA_SAVE]])
61
- ; CHECK-NEXT: [[HEAP:%.*]] = call ptr @malloc(i32 9)
62
+ ; CHECK-NEXT: [[HEAP:%.*]] = tail call ptr @malloc(i32 9)
62
63
; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr [[HEAP]], ptr [[TMPMEM]], i32 9, i1 false)
63
64
; CHECK-NEXT: call void @useit(ptr [[HEAP]])
64
65
; CHECK-NEXT: ret i32 0
@@ -74,7 +75,7 @@ define i32 @test_stackrestore() {
74
75
75
76
call void @llvm.memcpy.p0.p0.i32 (ptr %tmpmem , ptr %argmem , i32 10 , i1 false )
76
77
call void @llvm.stackrestore (ptr %inalloca.save )
77
- %heap = call ptr @malloc (i32 9 )
78
+ %heap = tail call ptr @malloc (i32 9 )
78
79
call void @llvm.memcpy.p0.p0.i32 (ptr %heap , ptr %tmpmem , i32 9 , i1 false )
79
80
call void @useit (ptr %heap )
80
81
ret i32 0
0 commit comments