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"
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]
9 ; Verify printf with no floating point arguments is transformed to iprintf
10 define i32 @f0(i32 %x) nounwind {
12 ; CHECK: define i32 @f0
15 %0 = tail call i32 (i8*, ...)* @printf(i8* getelementptr ([4 x i8]* @.str1, i32 0, i32 0), i32 %x) ; <i32> [#uses=0]
19 ; Verify we don't turn this into an iprintf call
20 define void @f1(double %x) nounwind {
22 ; CHECK: define void @f1
25 %0 = tail call i32 (i8*, ...)* @printf(i8* getelementptr ([4 x i8]* @.str, i32 0, i32 0), double %x) nounwind ; <i32> [#uses=0]
29 ; Verify sprintf with no floating point arguments is transformed to siprintf
30 define i32 @f2(i8* %p, i32 %x) nounwind {
32 ; CHECK: define i32 @f2
35 %0 = tail call i32 (i8*, i8*, ...)* @sprintf(i8 *%p, i8* getelementptr ([4 x i8]* @.str1, i32 0, i32 0), i32 %x)
39 ; Verify we don't turn this into an siprintf call
40 define i32 @f3(i8* %p, double %x) nounwind {
42 ; CHECK: define i32 @f3
45 %0 = tail call i32 (i8*, i8*, ...)* @sprintf(i8 *%p, i8* getelementptr ([4 x i8]* @.str, i32 0, i32 0), double %x)
49 ; Verify fprintf with no floating point arguments is transformed to fiprintf
50 define i32 @f4(i8* %p, i32 %x) nounwind {
52 ; CHECK: define i32 @f4
55 %0 = tail call i32 (i8*, i8*, ...)* @fprintf(i8 *%p, i8* getelementptr ([4 x i8]* @.str1, i32 0, i32 0), i32 %x)
59 ; Verify we don't turn this into an fiprintf call
60 define i32 @f5(i8* %p, double %x) nounwind {
62 ; CHECK: define i32 @f5
65 %0 = tail call i32 (i8*, i8*, ...)* @fprintf(i8 *%p, i8* getelementptr ([4 x i8]* @.str, i32 0, i32 0), double %x)
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