Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame^] | 1 | ; Test that the StrCatOptimizer works correctly |
| 2 | ; RUN: llvm-upgrade < %s | llvm-as | opt -simplify-libcalls | llvm-dis | \ |
| 3 | ; RUN: not grep {call.*strlen} |
| 4 | |
| 5 | target datalayout = "e-p:32:32" |
| 6 | |
| 7 | declare uint %strlen(sbyte*) |
| 8 | %hello = constant [6 x sbyte] c"hello\00" |
| 9 | %null = constant [1 x sbyte] c"\00" |
| 10 | %null_hello = constant [7 x sbyte] c"\00hello\00" |
| 11 | |
| 12 | implementation ; Functions: |
| 13 | |
| 14 | uint %test1() { |
| 15 | %hello_p = getelementptr [6 x sbyte]* %hello, int 0, int 0 |
| 16 | %hello_l = call uint %strlen(sbyte* %hello_p) |
| 17 | ret uint %hello_l |
| 18 | } |
| 19 | |
| 20 | uint %test2() { |
| 21 | %null_p = getelementptr [1 x sbyte]* %null, int 0, int 0 |
| 22 | %null_l = call uint %strlen(sbyte* %null_p) |
| 23 | ret uint %null_l |
| 24 | } |
| 25 | |
| 26 | uint %test3() { |
| 27 | %null_hello_p = getelementptr [7 x sbyte]* %null_hello, int 0, int 0 |
| 28 | %null_hello_l = call uint %strlen(sbyte* %null_hello_p) |
| 29 | ret uint %null_hello_l |
| 30 | } |
| 31 | |
| 32 | bool %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 | |
| 39 | bool %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 | |
| 46 | bool %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 | |
| 53 | bool %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 |
| 58 | } |