1 ; Test that the SPrintFOptimizer works correctly
2 ; RUN: llvm-upgrade < %s | llvm-as | opt -simplify-libcalls | llvm-dis | \
3 ; RUN: not grep {call.*sprintf}
5 declare int %sprintf(sbyte*,sbyte*,...)
6 declare int %puts(sbyte*)
7 %hello = constant [6 x sbyte] c"hello\00"
8 %null = constant [1 x sbyte] c"\00"
9 %null_hello = constant [7 x sbyte] c"\00hello\00"
10 %fmt1 = constant [3 x sbyte] c"%s\00"
11 %fmt2 = constant [3 x sbyte] c"%c\00"
13 implementation ; Functions:
15 int %foo (sbyte* %p) {
16 %target = alloca [1024 x sbyte]
17 %target_p = getelementptr [1024 x sbyte]* %target, int 0, int 0
18 %hello_p = getelementptr [6 x sbyte]* %hello, int 0, int 0
19 %null_p = getelementptr [1 x sbyte]* %null, int 0, int 0
20 %nh_p = getelementptr [7 x sbyte]* %null_hello, int 0, int 0
21 %fmt1_p = getelementptr [3 x sbyte]* %fmt1, int 0, int 0
22 %fmt2_p = getelementptr [3 x sbyte]* %fmt2, int 0, int 0
23 store sbyte 0, sbyte* %target_p
24 %r1 = call int (sbyte*,sbyte*,...)* %sprintf(sbyte* %target_p, sbyte* %hello_p)
25 %r2 = call int (sbyte*,sbyte*,...)* %sprintf(sbyte* %target_p, sbyte* %null_p)
26 %r3 = call int (sbyte*,sbyte*,...)* %sprintf(sbyte* %target_p, sbyte* %nh_p)
27 %r4 = call int (sbyte*,sbyte*,...)* %sprintf(sbyte* %target_p, sbyte* %fmt1_p, sbyte* %hello_p)
28 %r4.1 = call int (sbyte*,sbyte*,...)* %sprintf(sbyte* %target_p, sbyte* %fmt1_p, sbyte* %p)
29 %r5 = call int (sbyte*,sbyte*,...)* %sprintf(sbyte* %target_p, sbyte* %fmt2_p, int 82)
30 %r6 = add int %r1, %r2
31 %r7 = add int %r3, %r6
32 %r8 = add int %r5, %r7
33 %r9 = add int %r8, %r4
34 %r10 = add int %r9, %r4.1