blob: 3bae110475fe4e97fa32d48313cb9de4446e9a13 [file] [log] [blame]
Reid Spencer8fe86dd2005-04-26 05:22:38 +00001; Test that the StrCatOptimizer works correctly
2; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | not grep 'call.*strlen'
3
Reid Spencerc662bc72005-04-26 19:04:46 +00004declare uint %strlen(sbyte*)
Reid Spencer8fe86dd2005-04-26 05:22:38 +00005%hello = constant [6 x sbyte] c"hello\00"
6%null = constant [1 x sbyte] c"\00"
7%null_hello = constant [7 x sbyte] c"\00hello\00"
8
9implementation ; Functions:
10
11int %main () {
12 %hello_p = getelementptr [6 x sbyte]* %hello, int 0, int 0
Reid Spencerc662bc72005-04-26 19:04:46 +000013 %hello_l = call uint %strlen(sbyte* %hello_p)
Reid Spencer8fe86dd2005-04-26 05:22:38 +000014 %null_p = getelementptr [1 x sbyte]* %null, int 0, int 0
Reid Spencerc662bc72005-04-26 19:04:46 +000015 %null_l = call uint %strlen(sbyte* %null_p)
Reid Spencer8fe86dd2005-04-26 05:22:38 +000016 %null_hello_p = getelementptr [7 x sbyte]* %null_hello, int 0, int 0
Reid Spencerc662bc72005-04-26 19:04:46 +000017 %null_hello_l = call uint %strlen(sbyte* %null_hello_p)
Reid Spencer8fe86dd2005-04-26 05:22:38 +000018 %sum1 = add int %hello_l, %null_l
19 %sum2 = add int %sum1, %null_hello_l
20 ret int %sum2
21}