1; RUN: llc < %s -mtriple=thumbv7-apple-ios
2
3; If converter was being too cute. It look for root BBs (which don't have
4; successors) and use inverse depth first search to traverse the BBs. However
5; that doesn't work when the CFG has infinite loops. Simply do a linear
6; traversal of all BBs work just fine.
7
8; rdar://9344645
9
10%struct.hc = type { i32, i32, i32, i32 }
11
12define i32 @t(i32 %type) optsize {
13entry:
14  br i1 undef, label %if.then, label %if.else
15
16if.then:
17  unreachable
18
19if.else:
20  br i1 undef, label %if.then15, label %if.else18
21
22if.then15:
23  unreachable
24
25if.else18:
26  switch i32 %type, label %if.else173 [
27    i32 3, label %if.then115
28    i32 1, label %if.then102
29  ]
30
31if.then102:
32  br i1 undef, label %cond.true10.i, label %t.exit
33
34cond.true10.i:
35  br label %t.exit
36
37t.exit:
38  unreachable
39
40if.then115:
41  br i1 undef, label %if.else163, label %if.else145
42
43if.else145:
44  %call150 = call fastcc %struct.hc* @foo(%struct.hc* undef, i32 34865152) optsize
45  br label %while.body172
46
47if.else163:
48  %call168 = call fastcc %struct.hc* @foo(%struct.hc* undef, i32 34078720) optsize
49  br label %while.body172
50
51while.body172:
52  br label %while.body172
53
54if.else173:
55  ret i32 -1
56}
57
58declare hidden fastcc %struct.hc* @foo(%struct.hc* nocapture, i32) nounwind optsize
59
60