OLD | NEW |
| (Empty) |
1 ; Simple smoke test of the call instruction. The assembly checks | |
2 ; currently only verify the function labels. | |
3 | |
4 ; RUN: %p2i -i %s --args --verbose inst | FileCheck %s | |
5 ; RUN: %p2i -i %s --args --verbose none | FileCheck --check-prefix=ERRORS %s | |
6 ; RUN: %p2i -i %s --insts | %szdiff %s | FileCheck --check-prefix=DUMP %s | |
7 | |
8 define i32 @fib(i32 %n) { | |
9 ; CHECK: define i32 @fib | |
10 entry: | |
11 %cmp = icmp slt i32 %n, 2 | |
12 br i1 %cmp, label %return, label %if.end | |
13 | |
14 if.end: ; preds = %entry | |
15 %sub = add i32 %n, -1 | |
16 %call = tail call i32 @fib(i32 %sub) | |
17 %sub1 = add i32 %n, -2 | |
18 %call2 = tail call i32 @fib(i32 %sub1) | |
19 %add = add i32 %call2, %call | |
20 ret i32 %add | |
21 | |
22 return: ; preds = %entry | |
23 ret i32 %n | |
24 } | |
25 | |
26 define i32 @fact(i32 %n) { | |
27 ; CHECK: define i32 @fact | |
28 entry: | |
29 %cmp = icmp slt i32 %n, 2 | |
30 br i1 %cmp, label %return, label %if.end | |
31 | |
32 if.end: ; preds = %entry | |
33 %sub = add i32 %n, -1 | |
34 %call = tail call i32 @fact(i32 %sub) | |
35 %mul = mul i32 %call, %n | |
36 ret i32 %mul | |
37 | |
38 return: ; preds = %entry | |
39 ret i32 %n | |
40 } | |
41 | |
42 define i32 @redirect(i32 %n) { | |
43 ; CHECK: define i32 @redirect | |
44 entry: | |
45 %call = tail call i32 @redirect_target(i32 %n) | |
46 ret i32 %call | |
47 } | |
48 | |
49 declare i32 @redirect_target(i32) | |
50 | |
51 define void @call_void(i32 %n) { | |
52 ; CHECK: define void @call_void | |
53 | |
54 entry: | |
55 %cmp2 = icmp sgt i32 %n, 0 | |
56 br i1 %cmp2, label %if.then, label %if.end | |
57 | |
58 if.then: ; preds = %entry, %if.then | |
59 %n.tr3 = phi i32 [ %call.i, %if.then ], [ %n, %entry ] | |
60 %sub = add i32 %n.tr3, -1 | |
61 %call.i = tail call i32 @redirect_target(i32 %sub) | |
62 %cmp = icmp sgt i32 %call.i, 0 | |
63 br i1 %cmp, label %if.then, label %if.end | |
64 | |
65 if.end: ; preds = %if.then, %entry | |
66 ret void | |
67 } | |
68 | |
69 ; ERRORS-NOT: ICE translation error | |
70 ; DUMP-NOT: SZ | |
OLD | NEW |