aboutsummaryrefslogtreecommitdiff
path: root/test/Transforms
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2012-09-24 22:09:10 +0000
committerNick Lewycky <nicholas@mxc.ca>2012-09-24 22:09:10 +0000
commit3dbefbd9bb9801db3b8fda8e15d03f2659393135 (patch)
treec3c5192bb9198bd5c09604d8e9a7867d5c4ae70c /test/Transforms
parent97a1a6144721c2eec2323ff85a80f77b36b58c96 (diff)
Teach DSE that strcpy, strncpy, strcat and strncat are all stores which may be
dead. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164561 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms')
-rw-r--r--test/Transforms/DeadStoreElimination/libcalls.ll46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/Transforms/DeadStoreElimination/libcalls.ll b/test/Transforms/DeadStoreElimination/libcalls.ll
new file mode 100644
index 0000000000..b83780b399
--- /dev/null
+++ b/test/Transforms/DeadStoreElimination/libcalls.ll
@@ -0,0 +1,46 @@
+; RUN: opt -S -basicaa -dse < %s | FileCheck %s
+
+declare i8* @strcpy(i8* %dest, i8* %src) nounwind
+define void @test1(i8* %src) {
+; CHECK: @test1
+ %B = alloca [16 x i8]
+ %dest = getelementptr inbounds [16 x i8]* %B, i64 0, i64 0
+; CHECK-NOT: @strcpy
+ %call = call i8* @strcpy(i8* %dest, i8* %src)
+; CHECK: ret void
+ ret void
+}
+
+declare i8* @strncpy(i8* %dest, i8* %src, i32 %n) nounwind
+define void @test2(i8* %src) {
+; CHECK: @test2
+ %B = alloca [16 x i8]
+ %dest = getelementptr inbounds [16 x i8]* %B, i64 0, i64 0
+; CHECK-NOT: @strcpy
+ %call = call i8* @strncpy(i8* %dest, i8* %src, i32 12)
+; CHECK: ret void
+ ret void
+}
+
+declare i8* @strcat(i8* %dest, i8* %src) nounwind
+define void @test3(i8* %src) {
+; CHECK: @test3
+ %B = alloca [16 x i8]
+ %dest = getelementptr inbounds [16 x i8]* %B, i64 0, i64 0
+; CHECK-NOT: @strcpy
+ %call = call i8* @strcat(i8* %dest, i8* %src)
+; CHECK: ret void
+ ret void
+}
+
+declare i8* @strncat(i8* %dest, i8* %src, i32 %n) nounwind
+define void @test4(i8* %src) {
+; CHECK: @test4
+ %B = alloca [16 x i8]
+ %dest = getelementptr inbounds [16 x i8]* %B, i64 0, i64 0
+; CHECK-NOT: @strcpy
+ %call = call i8* @strncat(i8* %dest, i8* %src, i32 12)
+; CHECK: ret void
+ ret void
+}
+