blob: 6532a637c1934fff7aa24c889c1039ae8268fe82 [file] [log] [blame]
Reid Spencer0bc07502005-04-25 07:29:30 +00001; Test that the StrCatOptimizer works correctly
Reid Spencer69ccadd2006-12-02 04:23:10 +00002; RUN: llvm-upgrade < %s | llvm-as | opt -simplify-libcalls | llvm-dis | not grep 'call.*strcat'
Reid Spencer0bc07502005-04-25 07:29:30 +00003
4declare sbyte* %strcat(sbyte*,sbyte*)
Reid Spencer8b9f9b32005-04-25 21:08:34 +00005declare int %puts(sbyte*)
Reid Spencer0bc07502005-04-25 07:29:30 +00006%hello = constant [6 x sbyte] c"hello\00"
Reid Spencer8b9f9b32005-04-25 21:08:34 +00007%null = constant [1 x sbyte] c"\00"
8%null_hello = constant [7 x sbyte] c"\00hello\00"
Reid Spencer0bc07502005-04-25 07:29:30 +00009
10implementation ; Functions:
11
12int %main () {
13 %target = alloca [1024 x sbyte]
14 %arg1 = getelementptr [1024 x sbyte]* %target, int 0, int 0
Reid Spencer5fe85612005-04-25 15:40:35 +000015 store sbyte 0, sbyte* %arg1
Reid Spencer0bc07502005-04-25 07:29:30 +000016 %arg2 = getelementptr [6 x sbyte]* %hello, int 0, int 0
Reid Spencer8b9f9b32005-04-25 21:08:34 +000017 %rslt1 = call sbyte* %strcat(sbyte* %arg1, sbyte* %arg2)
18 %arg3 = getelementptr [1 x sbyte]* %null, int 0, int 0
19 %rslt2 = call sbyte* %strcat(sbyte* %rslt1, sbyte* %arg3)
20 %arg4 = getelementptr [7 x sbyte]* %null_hello, int 0, int 0
21 %rslt3 = call sbyte* %strcat(sbyte* %rslt2, sbyte* %arg4)
22 call int %puts(sbyte* %rslt3)
Reid Spencer0bc07502005-04-25 07:29:30 +000023 ret int 0
24}