2005-04-26 05:22:38 +00:00
|
|
|
; Test that the StrCatOptimizer works correctly
|
2006-12-02 04:23:10 +00:00
|
|
|
; RUN: llvm-upgrade < %s | llvm-as | opt -simplify-libcalls | llvm-dis | not grep 'call.*strlen'
|
2005-04-26 05:22:38 +00:00
|
|
|
|
2005-04-26 19:04:46 +00:00
|
|
|
declare uint %strlen(sbyte*)
|
2005-04-30 03:06:36 +00:00
|
|
|
%hello = constant [6 x sbyte] c"hello\00"
|
|
|
|
%null = constant [1 x sbyte] c"\00"
|
2005-04-26 05:22:38 +00:00
|
|
|
%null_hello = constant [7 x sbyte] c"\00hello\00"
|
|
|
|
|
|
|
|
implementation ; Functions:
|
|
|
|
|
2005-05-07 20:21:04 +00:00
|
|
|
uint %test1() {
|
2005-04-30 03:06:36 +00:00
|
|
|
%hello_p = getelementptr [6 x sbyte]* %hello, int 0, int 0
|
2005-05-07 20:21:04 +00:00
|
|
|
%hello_l = call uint %strlen(sbyte* %hello_p)
|
|
|
|
ret uint %hello_l
|
|
|
|
}
|
|
|
|
|
|
|
|
uint %test2() {
|
2005-04-30 03:06:36 +00:00
|
|
|
%null_p = getelementptr [1 x sbyte]* %null, int 0, int 0
|
2005-05-07 20:21:04 +00:00
|
|
|
%null_l = call uint %strlen(sbyte* %null_p)
|
|
|
|
ret uint %null_l
|
|
|
|
}
|
|
|
|
|
|
|
|
uint %test3() {
|
2005-04-26 05:22:38 +00:00
|
|
|
%null_hello_p = getelementptr [7 x sbyte]* %null_hello, int 0, int 0
|
2005-05-07 20:21:04 +00:00
|
|
|
%null_hello_l = call uint %strlen(sbyte* %null_hello_p)
|
|
|
|
ret uint %null_hello_l
|
|
|
|
}
|
|
|
|
|
|
|
|
bool %test4() {
|
|
|
|
%hello_p = getelementptr [6 x sbyte]* %hello, int 0, int 0
|
|
|
|
%hello_l = call uint %strlen(sbyte* %hello_p)
|
|
|
|
%eq_hello = seteq uint %hello_l, 0
|
|
|
|
ret bool %eq_hello
|
|
|
|
}
|
|
|
|
|
|
|
|
bool %test5() {
|
|
|
|
%null_p = getelementptr [1 x sbyte]* %null, int 0, int 0
|
|
|
|
%null_l = call uint %strlen(sbyte* %null_p)
|
|
|
|
%eq_null = seteq uint %null_l, 0
|
|
|
|
ret bool %eq_null
|
|
|
|
}
|
|
|
|
|
|
|
|
bool %test6() {
|
|
|
|
%hello_p = getelementptr [6 x sbyte]* %hello, int 0, int 0
|
2005-04-30 03:06:36 +00:00
|
|
|
%hello_l = call uint %strlen(sbyte* %hello_p)
|
2005-05-07 20:21:04 +00:00
|
|
|
%ne_hello = setne uint %hello_l, 0
|
|
|
|
ret bool %ne_hello
|
|
|
|
}
|
|
|
|
|
|
|
|
bool %test7() {
|
|
|
|
%null_p = getelementptr [1 x sbyte]* %null, int 0, int 0
|
2005-04-30 03:06:36 +00:00
|
|
|
%null_l = call uint %strlen(sbyte* %null_p)
|
2005-05-07 20:21:04 +00:00
|
|
|
%ne_null = setne uint %null_l, 0
|
|
|
|
ret bool %ne_null
|
2005-04-26 05:22:38 +00:00
|
|
|
}
|