1; RUN: opt -S -basicaa -dse < %s | FileCheck %s
2
3declare i8* @strcpy(i8* %dest, i8* %src) nounwind
4define void @test1(i8* %src) {
5; CHECK-LABEL: @test1(
6  %B = alloca [16 x i8]
7  %dest = getelementptr inbounds [16 x i8], [16 x i8]* %B, i64 0, i64 0
8; CHECK-NOT: @strcpy
9  %call = call i8* @strcpy(i8* %dest, i8* %src)
10; CHECK: ret void
11  ret void
12}
13
14declare i8* @strncpy(i8* %dest, i8* %src, i32 %n) nounwind
15define void @test2(i8* %src) {
16; CHECK-LABEL: @test2(
17  %B = alloca [16 x i8]
18  %dest = getelementptr inbounds [16 x i8], [16 x i8]* %B, i64 0, i64 0
19; CHECK-NOT: @strncpy
20  %call = call i8* @strncpy(i8* %dest, i8* %src, i32 12)
21; CHECK: ret void
22  ret void
23}
24
25declare i8* @strcat(i8* %dest, i8* %src) nounwind
26define void @test3(i8* %src) {
27; CHECK-LABEL: @test3(
28  %B = alloca [16 x i8]
29  %dest = getelementptr inbounds [16 x i8], [16 x i8]* %B, i64 0, i64 0
30; CHECK-NOT: @strcat
31  %call = call i8* @strcat(i8* %dest, i8* %src)
32; CHECK: ret void
33  ret void
34}
35
36declare i8* @strncat(i8* %dest, i8* %src, i32 %n) nounwind
37define void @test4(i8* %src) {
38; CHECK-LABEL: @test4(
39  %B = alloca [16 x i8]
40  %dest = getelementptr inbounds [16 x i8], [16 x i8]* %B, i64 0, i64 0
41; CHECK-NOT: @strncat
42  %call = call i8* @strncat(i8* %dest, i8* %src, i32 12)
43; CHECK: ret void
44  ret void
45}
46
47define void @test5(i8* nocapture %src) {
48; CHECK-LABEL: @test5(
49  %dest = alloca [100 x i8], align 16
50  %arraydecay = getelementptr inbounds [100 x i8], [100 x i8]* %dest, i64 0, i64 0
51  %call = call i8* @strcpy(i8* %arraydecay, i8* %src)
52; CHECK: %call = call i8* @strcpy
53  %arrayidx = getelementptr inbounds i8, i8* %call, i64 10
54  store i8 97, i8* %arrayidx, align 1
55  ret void
56}
57
58declare void @user(i8* %p)
59define void @test6(i8* %src) {
60; CHECK-LABEL: @test6(
61  %B = alloca [16 x i8]
62  %dest = getelementptr inbounds [16 x i8], [16 x i8]* %B, i64 0, i64 0
63; CHECK: @strcpy
64  %call = call i8* @strcpy(i8* %dest, i8* %src)
65; CHECK: @user
66  call void @user(i8* %dest)
67; CHECK: ret void
68  ret void
69}
70
71