Reid Spencer | 0bc0750 | 2005-04-25 07:29:30 +0000 | [diff] [blame] | 1 | ; Test that the StrCatOptimizer works correctly |
Reid Spencer | 43b4003 | 2007-04-16 15:31:49 +0000 | [diff] [blame] | 2 | ; RUN: llvm-upgrade < %s | llvm-as | opt -simplify-libcalls | llvm-dis | \ |
| 3 | ; RUN: not grep {call.*strcat} |
Reid Spencer | 0bc0750 | 2005-04-25 07:29:30 +0000 | [diff] [blame] | 4 | |
| 5 | declare sbyte* %strcat(sbyte*,sbyte*) |
Reid Spencer | 8b9f9b3 | 2005-04-25 21:08:34 +0000 | [diff] [blame] | 6 | declare int %puts(sbyte*) |
Reid Spencer | 0bc0750 | 2005-04-25 07:29:30 +0000 | [diff] [blame] | 7 | %hello = constant [6 x sbyte] c"hello\00" |
Reid Spencer | 8b9f9b3 | 2005-04-25 21:08:34 +0000 | [diff] [blame] | 8 | %null = constant [1 x sbyte] c"\00" |
| 9 | %null_hello = constant [7 x sbyte] c"\00hello\00" |
Reid Spencer | 0bc0750 | 2005-04-25 07:29:30 +0000 | [diff] [blame] | 10 | |
| 11 | implementation ; Functions: |
| 12 | |
| 13 | int %main () { |
| 14 | %target = alloca [1024 x sbyte] |
| 15 | %arg1 = getelementptr [1024 x sbyte]* %target, int 0, int 0 |
Reid Spencer | 5fe8561 | 2005-04-25 15:40:35 +0000 | [diff] [blame] | 16 | store sbyte 0, sbyte* %arg1 |
Reid Spencer | 0bc0750 | 2005-04-25 07:29:30 +0000 | [diff] [blame] | 17 | %arg2 = getelementptr [6 x sbyte]* %hello, int 0, int 0 |
Reid Spencer | 8b9f9b3 | 2005-04-25 21:08:34 +0000 | [diff] [blame] | 18 | %rslt1 = call sbyte* %strcat(sbyte* %arg1, sbyte* %arg2) |
| 19 | %arg3 = getelementptr [1 x sbyte]* %null, int 0, int 0 |
| 20 | %rslt2 = call sbyte* %strcat(sbyte* %rslt1, sbyte* %arg3) |
| 21 | %arg4 = getelementptr [7 x sbyte]* %null_hello, int 0, int 0 |
| 22 | %rslt3 = call sbyte* %strcat(sbyte* %rslt2, sbyte* %arg4) |
| 23 | call int %puts(sbyte* %rslt3) |
Reid Spencer | 0bc0750 | 2005-04-25 07:29:30 +0000 | [diff] [blame] | 24 | ret int 0 |
| 25 | } |