1; RUN: llc -simplifycfg-require-and-preserve-domtree=1 < %s -frame-pointer=all
2
3target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32-S128"
4target triple = "i386-apple-macosx10.7"
5
6; This test case has a landing pad with two predecessors, and a variable that
7; is undef on the first edge while carrying the first function return value on
8; the second edge.
9;
10; Live range splitting tries to isolate the block containing the first function
11; call, and it is important that the last split point is after the function call
12; so the return value can spill.
13;
14; <rdar://problem/10664933>
15
16@Exception = external unnamed_addr constant { i8*, i8* }
17
18declare void @llvm.memset.p0i8.i32(i8* nocapture, i8, i32, i1) nounwind
19
20define void @f(i32* nocapture %arg, i32* nocapture %arg1, i32* nocapture %arg2, i32* nocapture %arg3, i32 %arg4, i32 %arg5) optsize ssp personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
21bb:
22  br i1 undef, label %bb6, label %bb7
23
24bb6:                                              ; preds = %bb
25  %tmp = select i1 false, i32 0, i32 undef
26  br label %bb7
27
28bb7:                                              ; preds = %bb6, %bb
29  %tmp8 = phi i32 [ %tmp, %bb6 ], [ 0, %bb ]
30  %tmp9 = shl i32 %tmp8, 2
31  %tmp10 = invoke noalias i8* @_Znam(i32 undef) optsize
32          to label %bb11 unwind label %bb20
33
34bb11:                                             ; preds = %bb7
35  %tmp12 = ptrtoint i8* %tmp10 to i32
36  %tmp13 = bitcast i8* %tmp10 to i32*
37  %tmp14 = shl i32 %tmp8, 2
38  %tmp15 = getelementptr i32, i32* %tmp13, i32 undef
39  %tmp16 = getelementptr i32, i32* %tmp13, i32 undef
40  %tmp17 = zext i32 %tmp9 to i64
41  %tmp18 = add i64 %tmp17, -1
42  %tmp19 = icmp ugt i64 %tmp18, 4294967295
43  br i1 %tmp19, label %bb29, label %bb31
44
45bb20:                                             ; preds = %bb43, %bb41, %bb29, %bb7
46  %tmp21 = phi i32 [ undef, %bb7 ], [ %tmp12, %bb43 ], [ %tmp12, %bb29 ], [ %tmp12, %bb41 ]
47  %tmp22 = landingpad { i8*, i32 }
48          catch i8* bitcast ({ i8*, i8* }* @Exception to i8*)
49  br i1 undef, label %bb23, label %bb69
50
51bb23:                                             ; preds = %bb38, %bb20
52  %tmp24 = phi i32 [ %tmp12, %bb38 ], [ %tmp21, %bb20 ]
53  %tmp25 = icmp eq i32 %tmp24, 0
54  br i1 %tmp25, label %bb28, label %bb26
55
56bb26:                                             ; preds = %bb23
57  %tmp27 = inttoptr i32 %tmp24 to i8*
58  br label %bb28
59
60bb28:                                             ; preds = %bb26, %bb23
61  ret void
62
63bb29:                                             ; preds = %bb11
64  invoke void @OnOverFlow() optsize
65          to label %bb30 unwind label %bb20
66
67bb30:                                             ; preds = %bb29
68  unreachable
69
70bb31:                                             ; preds = %bb11
71  %tmp32 = bitcast i32* %tmp15 to i8*
72  %tmp33 = zext i32 %tmp8 to i64
73  %tmp34 = add i64 %tmp33, -1
74  %tmp35 = icmp ugt i64 %tmp34, 4294967295
75  %tmp36 = icmp sgt i32 %tmp8, 0
76  %tmp37 = add i32 %tmp9, -4
77  br label %bb38
78
79bb38:                                             ; preds = %bb67, %bb31
80  %tmp39 = phi i32 [ %tmp68, %bb67 ], [ undef, %bb31 ]
81  %tmp40 = icmp sgt i32 %tmp39, undef
82  br i1 %tmp40, label %bb41, label %bb23
83
84bb41:                                             ; preds = %bb38
85  invoke void @Pjii(i32* %tmp16, i32 0, i32 %tmp8) optsize
86          to label %bb42 unwind label %bb20
87
88bb42:                                             ; preds = %bb41
89  tail call void @llvm.memset.p0i8.i32(i8* %tmp32, i8 0, i32 %tmp9, i1 false) nounwind
90  br i1 %tmp35, label %bb43, label %bb45
91
92bb43:                                             ; preds = %bb42
93  invoke void @OnOverFlow() optsize
94          to label %bb44 unwind label %bb20
95
96bb44:                                             ; preds = %bb43
97  unreachable
98
99bb45:                                             ; preds = %bb57, %bb42
100  %tmp46 = phi i32 [ %tmp58, %bb57 ], [ 255, %bb42 ]
101  %tmp47 = icmp slt i32 undef, 0
102  br i1 %tmp47, label %bb48, label %bb59
103
104bb48:                                             ; preds = %bb45
105  tail call void @llvm.memset.p0i8.i32(i8* %tmp32, i8 0, i32 %tmp9, i1 false) nounwind
106  br i1 %tmp36, label %bb49, label %bb57
107
108bb49:                                             ; preds = %bb49, %bb48
109  %tmp50 = phi i32 [ %tmp55, %bb49 ], [ 0, %bb48 ]
110  %tmp51 = add i32 %tmp50, undef
111  %tmp52 = add i32 %tmp50, undef
112  %tmp53 = getelementptr i32, i32* %tmp13, i32 %tmp52
113  %tmp54 = load i32, i32* %tmp53, align 4
114  %tmp55 = add i32 %tmp50, 1
115  %tmp56 = icmp eq i32 %tmp55, %tmp8
116  br i1 %tmp56, label %bb57, label %bb49
117
118bb57:                                             ; preds = %bb49, %bb48
119  %tmp58 = add i32 %tmp46, -1
120  br label %bb45
121
122bb59:                                             ; preds = %bb45
123  %tmp60 = ashr i32 %tmp46, 31
124  tail call void @llvm.memset.p0i8.i32(i8* null, i8 0, i32 %tmp37, i1 false) nounwind
125  br i1 %tmp36, label %bb61, label %bb67
126
127bb61:                                             ; preds = %bb61, %bb59
128  %tmp62 = phi i32 [ %tmp65, %bb61 ], [ 0, %bb59 ]
129  %tmp63 = add i32 %tmp62, %tmp14
130  %tmp64 = getelementptr i32, i32* %tmp13, i32 %tmp63
131  store i32 0, i32* %tmp64, align 4
132  %tmp65 = add i32 %tmp62, 1
133  %tmp66 = icmp eq i32 %tmp65, %tmp8
134  br i1 %tmp66, label %bb67, label %bb61
135
136bb67:                                             ; preds = %bb61, %bb59
137  %tmp68 = add i32 %tmp39, -1
138  br label %bb38
139
140bb69:                                             ; preds = %bb20
141  resume { i8*, i32 } %tmp22
142}
143
144declare i32 @__gxx_personality_v0(...)
145
146declare noalias i8* @_Znam(i32) optsize
147
148declare void @Pjii(i32*, i32, i32) optsize
149
150declare i32 @llvm.eh.typeid.for(i8*) nounwind readnone
151
152declare void @OnOverFlow() noreturn optsize ssp align 2
153