blob: 48f8bfdcf3c8c28c6041f7d151b6211f6adf2d73 [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 Spencerabffafd2005-04-30 03:06:36 +00005%hello = constant [6 x sbyte] c"hello\00"
6%null = constant [1 x sbyte] c"\00"
Reid Spencer8fe86dd2005-04-26 05:22:38 +00007%null_hello = constant [7 x sbyte] c"\00hello\00"
8
9implementation ; Functions:
10
11int %main () {
Reid Spencerabffafd2005-04-30 03:06:36 +000012 %hello_p = getelementptr [6 x sbyte]* %hello, int 0, int 0
13 %null_p = getelementptr [1 x sbyte]* %null, int 0, int 0
Reid Spencer8fe86dd2005-04-26 05:22:38 +000014 %null_hello_p = getelementptr [7 x sbyte]* %null_hello, int 0, int 0
Reid Spencerabffafd2005-04-30 03:06:36 +000015 %hello_l = call uint %strlen(sbyte* %hello_p)
16 %null_l = call uint %strlen(sbyte* %null_p)
Reid Spencerc662bc72005-04-26 19:04:46 +000017 %null_hello_l = call uint %strlen(sbyte* %null_hello_p)
Reid Spencerabffafd2005-04-30 03:06:36 +000018 %sum1 = add uint %hello_l, %null_l
19 %sum2 = add uint %sum1, %null_hello_l
20 %result = cast uint %sum2 to int
21 ret int %result
Reid Spencer8fe86dd2005-04-26 05:22:38 +000022}