Teach DSE that strcpy, strncpy, strcat and strncat are all stores which may be
[oota-llvm.git] / test / Transforms / DeadStoreElimination / libcalls.ll
1 ; RUN: opt -S -basicaa -dse < %s | FileCheck %s
2
3 declare i8* @strcpy(i8* %dest, i8* %src) nounwind
4 define void @test1(i8* %src) {
5 ; CHECK: @test1
6   %B = alloca [16 x i8]
7   %dest = getelementptr inbounds [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
14 declare i8* @strncpy(i8* %dest, i8* %src, i32 %n) nounwind
15 define void @test2(i8* %src) {
16 ; CHECK: @test2
17   %B = alloca [16 x i8]
18   %dest = getelementptr inbounds [16 x i8]* %B, i64 0, i64 0
19 ; CHECK-NOT: @strcpy
20   %call = call i8* @strncpy(i8* %dest, i8* %src, i32 12)
21 ; CHECK: ret void
22   ret void
23 }
24
25 declare i8* @strcat(i8* %dest, i8* %src) nounwind
26 define void @test3(i8* %src) {
27 ; CHECK: @test3
28   %B = alloca [16 x i8]
29   %dest = getelementptr inbounds [16 x i8]* %B, i64 0, i64 0
30 ; CHECK-NOT: @strcpy
31   %call = call i8* @strcat(i8* %dest, i8* %src)
32 ; CHECK: ret void
33   ret void
34 }
35
36 declare i8* @strncat(i8* %dest, i8* %src, i32 %n) nounwind
37 define void @test4(i8* %src) {
38 ; CHECK: @test4
39   %B = alloca [16 x i8]
40   %dest = getelementptr inbounds [16 x i8]* %B, i64 0, i64 0
41 ; CHECK-NOT: @strcpy
42   %call = call i8* @strncat(i8* %dest, i8* %src, i32 12)
43 ; CHECK: ret void
44   ret void
45 }
46