summaryrefslogtreecommitdiff
path: root/test/Transforms/SimplifyLibCalls/StrLen.ll
blob: 20aa7a8dca3112e80a533c5d73a50123d1335522 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
; Test that the StrCatOptimizer works correctly
; RUN: llvm-upgrade < %s | llvm-as | opt -simplify-libcalls | llvm-dis | not grep 'call.*strlen'

declare uint %strlen(sbyte*)
%hello      = constant [6 x sbyte] c"hello\00"
%null       = constant [1 x sbyte] c"\00"
%null_hello = constant [7 x sbyte] c"\00hello\00"

implementation   ; Functions:

uint %test1() {
  %hello_p      = getelementptr [6 x sbyte]* %hello, int 0, int 0
  %hello_l      = call uint %strlen(sbyte* %hello_p)
  ret uint %hello_l
}

uint %test2() {
  %null_p       = getelementptr [1 x sbyte]* %null, int 0, int 0
  %null_l       = call uint %strlen(sbyte* %null_p)
  ret uint %null_l
}

uint %test3() {
  %null_hello_p = getelementptr [7 x sbyte]* %null_hello, int 0, int 0
  %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
  %hello_l      = call uint %strlen(sbyte* %hello_p)
  %ne_hello     = setne uint %hello_l, 0
  ret bool %ne_hello
}

bool %test7() {
  %null_p       = getelementptr [1 x sbyte]* %null, int 0, int 0
  %null_l       = call uint %strlen(sbyte* %null_p)
  %ne_null      = setne uint %null_l, 0
  ret bool %ne_null
}