1 ; RUN: opt < %s -simplify-libcalls -S -o %t 2 ; RUN: FileCheck < %t %s 3 target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:32-f32:32:32-f64:32:32-v64:64:64-v128:128:128-a0:0:32" 4 target triple = "xcore-xmos-elf" 5 6 @.str = internal constant [4 x i8] c"%f\0A\00" ; <[4 x i8]*> [#uses=1] 7 @.str1 = internal constant [4 x i8] c"%d\0A\00" ; <[4 x i8]*> [#uses=1] 8 9 ; Verify printf with no floating point arguments is transformed to iprintf 10 define i32 @f0(i32 %x) nounwind { 11 entry: 12 ; CHECK: define i32 @f0 13 ; CHECK: @iprintf 14 ; CHECK: } 15 %0 = tail call i32 (i8*, ...)* @printf(i8* getelementptr ([4 x i8]* @.str1, i32 0, i32 0), i32 %x) ; <i32> [#uses=0] 16 ret i32 %0 17 } 18 19 ; Verify we don't turn this into an iprintf call 20 define void @f1(double %x) nounwind { 21 entry: 22 ; CHECK: define void @f1 23 ; CHECK: @printf 24 ; CHECK: } 25 %0 = tail call i32 (i8*, ...)* @printf(i8* getelementptr ([4 x i8]* @.str, i32 0, i32 0), double %x) nounwind ; <i32> [#uses=0] 26 ret void 27 } 28 29 ; Verify sprintf with no floating point arguments is transformed to siprintf 30 define i32 @f2(i8* %p, i32 %x) nounwind { 31 entry: 32 ; CHECK: define i32 @f2 33 ; CHECK: @siprintf 34 ; CHECK: } 35 %0 = tail call i32 (i8*, i8*, ...)* @sprintf(i8 *%p, i8* getelementptr ([4 x i8]* @.str1, i32 0, i32 0), i32 %x) 36 ret i32 %0 37 } 38 39 ; Verify we don't turn this into an siprintf call 40 define i32 @f3(i8* %p, double %x) nounwind { 41 entry: 42 ; CHECK: define i32 @f3 43 ; CHECK: @sprintf 44 ; CHECK: } 45 %0 = tail call i32 (i8*, i8*, ...)* @sprintf(i8 *%p, i8* getelementptr ([4 x i8]* @.str, i32 0, i32 0), double %x) 46 ret i32 %0 47 } 48 49 ; Verify fprintf with no floating point arguments is transformed to fiprintf 50 define i32 @f4(i8* %p, i32 %x) nounwind { 51 entry: 52 ; CHECK: define i32 @f4 53 ; CHECK: @fiprintf 54 ; CHECK: } 55 %0 = tail call i32 (i8*, i8*, ...)* @fprintf(i8 *%p, i8* getelementptr ([4 x i8]* @.str1, i32 0, i32 0), i32 %x) 56 ret i32 %0 57 } 58 59 ; Verify we don't turn this into an fiprintf call 60 define i32 @f5(i8* %p, double %x) nounwind { 61 entry: 62 ; CHECK: define i32 @f5 63 ; CHECK: @fprintf 64 ; CHECK: } 65 %0 = tail call i32 (i8*, i8*, ...)* @fprintf(i8 *%p, i8* getelementptr ([4 x i8]* @.str, i32 0, i32 0), double %x) 66 ret i32 %0 67 } 68 69 declare i32 @printf(i8* nocapture, ...) nounwind 70 declare i32 @sprintf(i8* nocapture, i8* nocapture, ...) nounwind 71 declare i32 @fprintf(i8* nocapture, i8* nocapture, ...) nounwind 72