blob: d50b7c573f58fec27c5f1120a44feb65d36895cc [file] [log] [blame]
Reid Spencer8fe86dd2005-04-26 05:22:38 +00001; Test that the StrCatOptimizer works correctly
Reid Spencere3ff5ad2007-01-26 08:25:06 +00002; RUN: llvm-upgrade < %s | llvm-as | opt -simplify-libcalls | llvm-dis | \
3; RUN: not grep 'call.*strlen'
4
5target datalayout = "e-p:32:32"
Reid Spencer8fe86dd2005-04-26 05:22:38 +00006
Reid Spencerc662bc72005-04-26 19:04:46 +00007declare uint %strlen(sbyte*)
Reid Spencerabffafd2005-04-30 03:06:36 +00008%hello = constant [6 x sbyte] c"hello\00"
9%null = constant [1 x sbyte] c"\00"
Reid Spencer8fe86dd2005-04-26 05:22:38 +000010%null_hello = constant [7 x sbyte] c"\00hello\00"
11
12implementation ; Functions:
13
Reid Spencer29a5bf52005-05-07 20:21:04 +000014uint %test1() {
Reid Spencerabffafd2005-04-30 03:06:36 +000015 %hello_p = getelementptr [6 x sbyte]* %hello, int 0, int 0
Reid Spencerabffafd2005-04-30 03:06:36 +000016 %hello_l = call uint %strlen(sbyte* %hello_p)
Reid Spencer29a5bf52005-05-07 20:21:04 +000017 ret uint %hello_l
18}
19
20uint %test2() {
21 %null_p = getelementptr [1 x sbyte]* %null, int 0, int 0
Reid Spencerabffafd2005-04-30 03:06:36 +000022 %null_l = call uint %strlen(sbyte* %null_p)
Reid Spencer29a5bf52005-05-07 20:21:04 +000023 ret uint %null_l
24}
25
26uint %test3() {
27 %null_hello_p = getelementptr [7 x sbyte]* %null_hello, int 0, int 0
Reid Spencerc662bc72005-04-26 19:04:46 +000028 %null_hello_l = call uint %strlen(sbyte* %null_hello_p)
Reid Spencer29a5bf52005-05-07 20:21:04 +000029 ret uint %null_hello_l
30}
31
32bool %test4() {
33 %hello_p = getelementptr [6 x sbyte]* %hello, int 0, int 0
34 %hello_l = call uint %strlen(sbyte* %hello_p)
35 %eq_hello = seteq uint %hello_l, 0
36 ret bool %eq_hello
37}
38
39bool %test5() {
40 %null_p = getelementptr [1 x sbyte]* %null, int 0, int 0
41 %null_l = call uint %strlen(sbyte* %null_p)
42 %eq_null = seteq uint %null_l, 0
43 ret bool %eq_null
44}
45
46bool %test6() {
47 %hello_p = getelementptr [6 x sbyte]* %hello, int 0, int 0
48 %hello_l = call uint %strlen(sbyte* %hello_p)
49 %ne_hello = setne uint %hello_l, 0
50 ret bool %ne_hello
51}
52
53bool %test7() {
54 %null_p = getelementptr [1 x sbyte]* %null, int 0, int 0
55 %null_l = call uint %strlen(sbyte* %null_p)
56 %ne_null = setne uint %null_l, 0
57 ret bool %ne_null
Reid Spencer8fe86dd2005-04-26 05:22:38 +000058}