Reid Spencer | 8fe86dd | 2005-04-26 05:22:38 +0000 | [diff] [blame] | 1 | ; Test that the StrCatOptimizer works correctly |
| 2 | ; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | not grep 'call.*strlen' |
| 3 | |
Reid Spencer | c662bc7 | 2005-04-26 19:04:46 +0000 | [diff] [blame] | 4 | declare uint %strlen(sbyte*) |
Reid Spencer | abffafd | 2005-04-30 03:06:36 +0000 | [diff] [blame] | 5 | %hello = constant [6 x sbyte] c"hello\00" |
| 6 | %null = constant [1 x sbyte] c"\00" |
Reid Spencer | 8fe86dd | 2005-04-26 05:22:38 +0000 | [diff] [blame] | 7 | %null_hello = constant [7 x sbyte] c"\00hello\00" |
| 8 | |
| 9 | implementation ; Functions: |
| 10 | |
Reid Spencer | 29a5bf5 | 2005-05-07 20:21:04 +0000 | [diff] [blame^] | 11 | uint %test1() { |
Reid Spencer | abffafd | 2005-04-30 03:06:36 +0000 | [diff] [blame] | 12 | %hello_p = getelementptr [6 x sbyte]* %hello, int 0, int 0 |
Reid Spencer | abffafd | 2005-04-30 03:06:36 +0000 | [diff] [blame] | 13 | %hello_l = call uint %strlen(sbyte* %hello_p) |
Reid Spencer | 29a5bf5 | 2005-05-07 20:21:04 +0000 | [diff] [blame^] | 14 | ret uint %hello_l |
| 15 | } |
| 16 | |
| 17 | uint %test2() { |
| 18 | %null_p = getelementptr [1 x sbyte]* %null, int 0, int 0 |
Reid Spencer | abffafd | 2005-04-30 03:06:36 +0000 | [diff] [blame] | 19 | %null_l = call uint %strlen(sbyte* %null_p) |
Reid Spencer | 29a5bf5 | 2005-05-07 20:21:04 +0000 | [diff] [blame^] | 20 | ret uint %null_l |
| 21 | } |
| 22 | |
| 23 | uint %test3() { |
| 24 | %null_hello_p = getelementptr [7 x sbyte]* %null_hello, int 0, int 0 |
Reid Spencer | c662bc7 | 2005-04-26 19:04:46 +0000 | [diff] [blame] | 25 | %null_hello_l = call uint %strlen(sbyte* %null_hello_p) |
Reid Spencer | 29a5bf5 | 2005-05-07 20:21:04 +0000 | [diff] [blame^] | 26 | ret uint %null_hello_l |
| 27 | } |
| 28 | |
| 29 | bool %test4() { |
| 30 | %hello_p = getelementptr [6 x sbyte]* %hello, int 0, int 0 |
| 31 | %hello_l = call uint %strlen(sbyte* %hello_p) |
| 32 | %eq_hello = seteq uint %hello_l, 0 |
| 33 | ret bool %eq_hello |
| 34 | } |
| 35 | |
| 36 | bool %test5() { |
| 37 | %null_p = getelementptr [1 x sbyte]* %null, int 0, int 0 |
| 38 | %null_l = call uint %strlen(sbyte* %null_p) |
| 39 | %eq_null = seteq uint %null_l, 0 |
| 40 | ret bool %eq_null |
| 41 | } |
| 42 | |
| 43 | bool %test6() { |
| 44 | %hello_p = getelementptr [6 x sbyte]* %hello, int 0, int 0 |
| 45 | %hello_l = call uint %strlen(sbyte* %hello_p) |
| 46 | %ne_hello = setne uint %hello_l, 0 |
| 47 | ret bool %ne_hello |
| 48 | } |
| 49 | |
| 50 | bool %test7() { |
| 51 | %null_p = getelementptr [1 x sbyte]* %null, int 0, int 0 |
| 52 | %null_l = call uint %strlen(sbyte* %null_p) |
| 53 | %ne_null = setne uint %null_l, 0 |
| 54 | ret bool %ne_null |
Reid Spencer | 8fe86dd | 2005-04-26 05:22:38 +0000 | [diff] [blame] | 55 | } |