blob: d17b038732770426c470e418ce3b4c2d95a8cd1f [file] [log] [blame]
Reid Spencer82be9852005-05-03 17:08:45 +00001; Test that the SPrintFOptimizer works correctly
2; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | not grep 'call.*sprintf'
3
4declare int %sprintf(sbyte*,sbyte*,...)
5declare int %puts(sbyte*)
6%hello = constant [6 x sbyte] c"hello\00"
7%null = constant [1 x sbyte] c"\00"
8%null_hello = constant [7 x sbyte] c"\00hello\00"
9%fmt1 = constant [3 x sbyte] c"%s\00"
10%fmt2 = constant [3 x sbyte] c"%c\00"
11
12implementation ; Functions:
13
14int %main () {
15 %target = alloca [1024 x sbyte]
16 %target_p = getelementptr [1024 x sbyte]* %target, int 0, int 0
17 %hello_p = getelementptr [6 x sbyte]* %hello, int 0, int 0
18 %null_p = getelementptr [1 x sbyte]* %null, int 0, int 0
19 %nh_p = getelementptr [7 x sbyte]* %null_hello, int 0, int 0
20 %fmt1_p = getelementptr [3 x sbyte]* %fmt1, int 0, int 0
21 %fmt2_p = getelementptr [3 x sbyte]* %fmt2, int 0, int 0
22 store sbyte 0, sbyte* %target_p
23 %r1 = call int (sbyte*,sbyte*,...)* %sprintf(sbyte* %target_p, sbyte* %hello_p)
24 %r2 = call int (sbyte*,sbyte*,...)* %sprintf(sbyte* %target_p, sbyte* %null_p)
25 %r3 = call int (sbyte*,sbyte*,...)* %sprintf(sbyte* %target_p, sbyte* %nh_p)
26 %r4 = call int (sbyte*,sbyte*,...)* %sprintf(sbyte* %target_p, sbyte* %fmt1_p, sbyte* %hello_p)
27 %r5 = call int (sbyte*,sbyte*,...)* %sprintf(sbyte* %target_p, sbyte* %fmt2_p, int 82)
28 %r6 = add int %r1, %r2
29 %r7 = add int %r3, %r6
30 %r8 = add int %r5, %r7
31 ret int %r8
32}