File: StrSpn.ll

package info (click to toggle)
llvm-3.0 3.0-10
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 75,412 kB
  • sloc: cpp: 468,043; asm: 109,345; ansic: 13,782; sh: 12,935; ml: 4,716; python: 4,351; perl: 2,096; makefile: 1,905; pascal: 1,578; exp: 389; xml: 283; lisp: 187; csh: 117
file content (41 lines) | stat: -rw-r--r-- 1,387 bytes parent folder | download | duplicates (4)
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
; RUN: opt < %s -simplify-libcalls -S | FileCheck %s

target datalayout = "-p:64:64:64"

@abcba = constant [6 x i8] c"abcba\00"
@abc = constant [4 x i8] c"abc\00"
@null = constant [1 x i8] zeroinitializer

declare i64 @strspn(i8*, i8*)

define i64 @testspn(i8* %s1, i8* %s2) {
  	%abcba_p = getelementptr [6 x i8]* @abcba, i32 0, i32 0
	%abc_p = getelementptr [4 x i8]* @abc, i32 0, i32 0
	%null_p = getelementptr [1 x i8]* @null, i32 0, i32 0
	%test1 = call i64 @strspn(i8* %s1, i8* %null_p)
	%test2 = call i64 @strspn(i8* %null_p, i8* %s2)
	%test3 = call i64 @strspn(i8* %abcba_p, i8* %abc_p)
; CHECK-NOT: call i64 @strspn
	%test4 = call i64 @strspn(i8* %s1, i8* %s2)
; CHECK: call i64 @strspn(i8* %s1, i8* %s2)
	ret i64 %test3
; CHECK: ret i64 5
}

declare i64 @strcspn(i8*, i8*)

define i64 @testcspn(i8* %s1, i8* %s2) {
  	%abcba_p = getelementptr [6 x i8]* @abcba, i32 0, i32 0
	%abc_p = getelementptr [4 x i8]* @abc, i32 0, i32 0
	%null_p = getelementptr [1 x i8]* @null, i32 0, i32 0
	%test1 = call i64 @strcspn(i8* %s1, i8* %null_p)
; CHECK: call i64 @strlen(i8* %s1)
	%test2 = call i64 @strcspn(i8* %null_p, i8* %s2)
	%test3 = call i64 @strcspn(i8* %abcba_p, i8* %abc_p)
; CHECK-NOT: call i64 @strcspn
	%test4 = call i64 @strcspn(i8* %s1, i8* %s2)
; CHECK: call i64 @strcspn(i8* %s1, i8* %s2)
        %add0 = add i64 %test1, %test3
; CHECK: add i64 %{{.+}}, 0
	ret i64 %add0
}