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