[llvm-commits] [llvm] r164561 - in /llvm/trunk: lib/Transforms/Scalar/DeadStoreElimination.cpp test/Transforms/DeadStoreElimination/libcalls.ll

Nuno Lopes nunoplopes at sapo.pt
Tue Sep 25 11:09:32 PDT 2012


> --- llvm/trunk/test/Transforms/DeadStoreElimination/libcalls.ll (added)
> +++ llvm/trunk/test/Transforms/DeadStoreElimination/libcalls.ll Mon Sep 24 
> 17:09:10 2012
> @@ -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

^ copy-pasto

> +  %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

^ idem

> +  %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

^ idem

> +  %call = call i8* @strncat(i8* %dest, i8* %src, i32 12)
> +; CHECK: ret void
> +  ret void
> +}
> +
>

BTW, it's probably nice to have a test to check that e.g. a strcpy to a ptr 
that escapes isn't removed.

Nuno 




More information about the llvm-commits mailing list