Revert 72493 and replace it with a more conservative fix, for now: don't
[oota-llvm.git] / test / Transforms / SimplifyLibCalls / StrCat.ll
1 ; Test that the StrCatOptimizer works correctly
2 ; PR3661
3 ; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | \
4 ; RUN:   not grep {call.*strcat}
5 ; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | \
6 ; RUN:   grep {puts.*%arg1}
7
8 @hello = constant [6 x i8] c"hello\00"          ; <[6 x i8]*> [#uses=1]
9 @null = constant [1 x i8] zeroinitializer               ; <[1 x i8]*> [#uses=1]
10 @null_hello = constant [7 x i8] c"\00hello\00"          ; <[7 x i8]*> [#uses=1]
11
12 declare i8* @strcat(i8*, i8*)
13
14 declare i32 @puts(i8*)
15
16 define i32 @main() {
17         %target = alloca [1024 x i8]            ; <[1024 x i8]*> [#uses=1]
18         %arg1 = getelementptr [1024 x i8]* %target, i32 0, i32 0                ; <i8*> [#uses=2]
19         store i8 0, i8* %arg1
20         %arg2 = getelementptr [6 x i8]* @hello, i32 0, i32 0            ; <i8*> [#uses=1]
21         %rslt1 = call i8* @strcat( i8* %arg1, i8* %arg2 )               ; <i8*> [#uses=1]
22         %arg3 = getelementptr [1 x i8]* @null, i32 0, i32 0             ; <i8*> [#uses=1]
23         %rslt2 = call i8* @strcat( i8* %rslt1, i8* %arg3 )              ; <i8*> [#uses=1]
24         %arg4 = getelementptr [7 x i8]* @null_hello, i32 0, i32 0               ; <i8*> [#uses=1]
25         %rslt3 = call i8* @strcat( i8* %rslt2, i8* %arg4 )              ; <i8*> [#uses=1]
26         call i32 @puts( i8* %rslt3 )            ; <i32>:1 [#uses=0]
27         ret i32 0
28 }
29