Home | History | Annotate | Download | only in SimplifyLibCalls
      1 ; RUN: opt < %s -simplify-libcalls -S | FileCheck %s
      2 
      3 target datalayout = "-p:64:64:64"
      4 
      5 @abcba = constant [6 x i8] c"abcba\00"
      6 @abc = constant [4 x i8] c"abc\00"
      7 @null = constant [1 x i8] zeroinitializer
      8 
      9 declare i64 @strspn(i8*, i8*)
     10 
     11 define i64 @testspn(i8* %s1, i8* %s2) {
     12   	%abcba_p = getelementptr [6 x i8]* @abcba, i32 0, i32 0
     13 	%abc_p = getelementptr [4 x i8]* @abc, i32 0, i32 0
     14 	%null_p = getelementptr [1 x i8]* @null, i32 0, i32 0
     15 	%test1 = call i64 @strspn(i8* %s1, i8* %null_p)
     16 	%test2 = call i64 @strspn(i8* %null_p, i8* %s2)
     17 	%test3 = call i64 @strspn(i8* %abcba_p, i8* %abc_p)
     18 ; CHECK-NOT: call i64 @strspn
     19 	%test4 = call i64 @strspn(i8* %s1, i8* %s2)
     20 ; CHECK: call i64 @strspn(i8* %s1, i8* %s2)
     21 	ret i64 %test3
     22 ; CHECK: ret i64 5
     23 }
     24 
     25 declare i64 @strcspn(i8*, i8*)
     26 
     27 define i64 @testcspn(i8* %s1, i8* %s2) {
     28   	%abcba_p = getelementptr [6 x i8]* @abcba, i32 0, i32 0
     29 	%abc_p = getelementptr [4 x i8]* @abc, i32 0, i32 0
     30 	%null_p = getelementptr [1 x i8]* @null, i32 0, i32 0
     31 	%test1 = call i64 @strcspn(i8* %s1, i8* %null_p)
     32 ; CHECK: call i64 @strlen(i8* %s1)
     33 	%test2 = call i64 @strcspn(i8* %null_p, i8* %s2)
     34 	%test3 = call i64 @strcspn(i8* %abcba_p, i8* %abc_p)
     35 ; CHECK-NOT: call i64 @strcspn
     36 	%test4 = call i64 @strcspn(i8* %s1, i8* %s2)
     37 ; CHECK: call i64 @strcspn(i8* %s1, i8* %s2)
     38         %add0 = add i64 %test1, %test3
     39 ; CHECK: add i64 %{{.+}}, 0
     40 	ret i64 %add0
     41 }
     42