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 | |
| 11 | int %main () { |
Reid Spencer | abffafd | 2005-04-30 03:06:36 +0000 | [diff] [blame^] | 12 | %hello_p = getelementptr [6 x sbyte]* %hello, int 0, int 0 |
| 13 | %null_p = getelementptr [1 x sbyte]* %null, int 0, int 0 |
Reid Spencer | 8fe86dd | 2005-04-26 05:22:38 +0000 | [diff] [blame] | 14 | %null_hello_p = getelementptr [7 x sbyte]* %null_hello, int 0, int 0 |
Reid Spencer | abffafd | 2005-04-30 03:06:36 +0000 | [diff] [blame^] | 15 | %hello_l = call uint %strlen(sbyte* %hello_p) |
| 16 | %null_l = call uint %strlen(sbyte* %null_p) |
Reid Spencer | c662bc7 | 2005-04-26 19:04:46 +0000 | [diff] [blame] | 17 | %null_hello_l = call uint %strlen(sbyte* %null_hello_p) |
Reid Spencer | abffafd | 2005-04-30 03:06:36 +0000 | [diff] [blame^] | 18 | %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 Spencer | 8fe86dd | 2005-04-26 05:22:38 +0000 | [diff] [blame] | 22 | } |