1; RUN: llc < %s -verify-machineinstrs
2; PR13188
3;
4; The _Unwind_RaiseException function can return normally and via eh.return.
5; This causes confusion about the function live-out registers, since the two
6; different ways of returning have different return values.
7;
8target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
9target triple = "x86_64-unknown-freebsd9.0"
10
11%struct._Unwind_Context = type { [18 x i8*], i8*, i8*, i8*, %struct.dwarf_eh_bases, i64, i64, i64, [18 x i8] }
12%struct.dwarf_eh_bases = type { i8*, i8*, i8* }
13%struct._Unwind_FrameState = type { %struct.frame_state_reg_info, i64, i64, i8*, i32, i8*, i32 (i32, i32, i64, %struct._Unwind_Exception*, %struct._Unwind_Context*)*, i64, i64, i64, i8, i8, i8, i8, i8* }
14%struct.frame_state_reg_info = type { [18 x %struct.anon], %struct.frame_state_reg_info* }
15%struct.anon = type { %union.anon, i32 }
16%union.anon = type { i64 }
17%struct._Unwind_Exception = type { i64, void (i32, %struct._Unwind_Exception*)*, i64, i64 }
18
19@dwarf_reg_size_table = external hidden unnamed_addr global [18 x i8], align 16
20
21declare void @abort() noreturn
22
23declare fastcc i32 @uw_frame_state_for(%struct._Unwind_Context*, %struct._Unwind_FrameState*) uwtable
24
25define hidden i32 @_Unwind_RaiseException(%struct._Unwind_Exception* %exc) uwtable {
26entry:
27  %fs.i = alloca %struct._Unwind_FrameState, align 8
28  %this_context = alloca %struct._Unwind_Context, align 8
29  %cur_context = alloca %struct._Unwind_Context, align 8
30  %fs = alloca %struct._Unwind_FrameState, align 8
31  call void @llvm.eh.unwind.init()
32  %0 = call i8* @llvm.eh.dwarf.cfa(i32 0)
33  %1 = call i8* @llvm.returnaddress(i32 0)
34  call fastcc void @uw_init_context_1(%struct._Unwind_Context* %this_context, i8* %0, i8* %1)
35  %2 = bitcast %struct._Unwind_Context* %cur_context to i8*
36  %3 = bitcast %struct._Unwind_Context* %this_context to i8*
37  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %2, i8* %3, i64 240, i32 8, i1 false)
38  %personality = getelementptr inbounds %struct._Unwind_FrameState, %struct._Unwind_FrameState* %fs, i64 0, i32 6
39  %retaddr_column.i = getelementptr inbounds %struct._Unwind_FrameState, %struct._Unwind_FrameState* %fs, i64 0, i32 9
40  %flags.i.i.i.i = getelementptr inbounds %struct._Unwind_Context, %struct._Unwind_Context* %cur_context, i64 0, i32 5
41  %ra.i = getelementptr inbounds %struct._Unwind_Context, %struct._Unwind_Context* %cur_context, i64 0, i32 2
42  %exception_class = getelementptr inbounds %struct._Unwind_Exception, %struct._Unwind_Exception* %exc, i64 0, i32 0
43  br label %while.body
44
45while.body:                                       ; preds = %uw_update_context.exit, %entry
46  %call = call fastcc i32 @uw_frame_state_for(%struct._Unwind_Context* %cur_context, %struct._Unwind_FrameState* %fs)
47  switch i32 %call, label %do.end21 [
48    i32 5, label %do.end21.loopexit46
49    i32 0, label %if.end3
50  ]
51
52if.end3:                                          ; preds = %while.body
53  %4 = load i32 (i32, i32, i64, %struct._Unwind_Exception*, %struct._Unwind_Context*)*, i32 (i32, i32, i64, %struct._Unwind_Exception*, %struct._Unwind_Context*)** %personality, align 8
54  %tobool = icmp eq i32 (i32, i32, i64, %struct._Unwind_Exception*, %struct._Unwind_Context*)* %4, null
55  br i1 %tobool, label %if.end13, label %if.then4
56
57if.then4:                                         ; preds = %if.end3
58  %5 = load i64, i64* %exception_class, align 8
59  %call6 = call i32 %4(i32 1, i32 1, i64 %5, %struct._Unwind_Exception* %exc, %struct._Unwind_Context* %cur_context)
60  switch i32 %call6, label %do.end21.loopexit46 [
61    i32 6, label %while.end
62    i32 8, label %if.end13
63  ]
64
65if.end13:                                         ; preds = %if.then4, %if.end3
66  call fastcc void @uw_update_context_1(%struct._Unwind_Context* %cur_context, %struct._Unwind_FrameState* %fs)
67  %6 = load i64, i64* %retaddr_column.i, align 8
68  %conv.i = trunc i64 %6 to i32
69  %cmp.i.i.i = icmp slt i32 %conv.i, 18
70  br i1 %cmp.i.i.i, label %cond.end.i.i.i, label %cond.true.i.i.i
71
72cond.true.i.i.i:                                  ; preds = %if.end13
73  call void @abort() noreturn
74  unreachable
75
76cond.end.i.i.i:                                   ; preds = %if.end13
77  %sext.i = shl i64 %6, 32
78  %idxprom.i.i.i = ashr exact i64 %sext.i, 32
79  %arrayidx.i.i.i = getelementptr inbounds [18 x i8], [18 x i8]* @dwarf_reg_size_table, i64 0, i64 %idxprom.i.i.i
80  %7 = load i8, i8* %arrayidx.i.i.i, align 1
81  %arrayidx2.i.i.i = getelementptr inbounds %struct._Unwind_Context, %struct._Unwind_Context* %cur_context, i64 0, i32 0, i64 %idxprom.i.i.i
82  %8 = load i8*, i8** %arrayidx2.i.i.i, align 8
83  %9 = load i64, i64* %flags.i.i.i.i, align 8
84  %and.i.i.i.i = and i64 %9, 4611686018427387904
85  %tobool.i.i.i = icmp eq i64 %and.i.i.i.i, 0
86  br i1 %tobool.i.i.i, label %if.end.i.i.i, label %land.lhs.true.i.i.i
87
88land.lhs.true.i.i.i:                              ; preds = %cond.end.i.i.i
89  %arrayidx4.i.i.i = getelementptr inbounds %struct._Unwind_Context, %struct._Unwind_Context* %cur_context, i64 0, i32 8, i64 %idxprom.i.i.i
90  %10 = load i8, i8* %arrayidx4.i.i.i, align 1
91  %tobool6.i.i.i = icmp eq i8 %10, 0
92  br i1 %tobool6.i.i.i, label %if.end.i.i.i, label %if.then.i.i.i
93
94if.then.i.i.i:                                    ; preds = %land.lhs.true.i.i.i
95  %11 = ptrtoint i8* %8 to i64
96  br label %uw_update_context.exit
97
98if.end.i.i.i:                                     ; preds = %land.lhs.true.i.i.i, %cond.end.i.i.i
99  %cmp8.i.i.i = icmp eq i8 %7, 8
100  br i1 %cmp8.i.i.i, label %if.then10.i.i.i, label %cond.true14.i.i.i
101
102if.then10.i.i.i:                                  ; preds = %if.end.i.i.i
103  %12 = bitcast i8* %8 to i64*
104  %13 = load i64, i64* %12, align 8
105  br label %uw_update_context.exit
106
107cond.true14.i.i.i:                                ; preds = %if.end.i.i.i
108  call void @abort() noreturn
109  unreachable
110
111uw_update_context.exit:                           ; preds = %if.then10.i.i.i, %if.then.i.i.i
112  %retval.0.i.i.i = phi i64 [ %11, %if.then.i.i.i ], [ %13, %if.then10.i.i.i ]
113  %14 = inttoptr i64 %retval.0.i.i.i to i8*
114  store i8* %14, i8** %ra.i, align 8
115  br label %while.body
116
117while.end:                                        ; preds = %if.then4
118  %private_1 = getelementptr inbounds %struct._Unwind_Exception, %struct._Unwind_Exception* %exc, i64 0, i32 2
119  store i64 0, i64* %private_1, align 8
120  %15 = load i8*, i8** %ra.i, align 8
121  %16 = ptrtoint i8* %15 to i64
122  %private_2 = getelementptr inbounds %struct._Unwind_Exception, %struct._Unwind_Exception* %exc, i64 0, i32 3
123  store i64 %16, i64* %private_2, align 8
124  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %2, i8* %3, i64 240, i32 8, i1 false)
125  %17 = bitcast %struct._Unwind_FrameState* %fs.i to i8*
126  call void @llvm.lifetime.start(i64 -1, i8* %17)
127  %personality.i = getelementptr inbounds %struct._Unwind_FrameState, %struct._Unwind_FrameState* %fs.i, i64 0, i32 6
128  %retaddr_column.i22 = getelementptr inbounds %struct._Unwind_FrameState, %struct._Unwind_FrameState* %fs.i, i64 0, i32 9
129  br label %while.body.i
130
131while.body.i:                                     ; preds = %uw_update_context.exit44, %while.end
132  %call.i = call fastcc i32 @uw_frame_state_for(%struct._Unwind_Context* %cur_context, %struct._Unwind_FrameState* %fs.i)
133  %18 = load i8*, i8** %ra.i, align 8
134  %19 = ptrtoint i8* %18 to i64
135  %20 = load i64, i64* %private_2, align 8
136  %cmp.i = icmp eq i64 %19, %20
137  %cmp2.i = icmp eq i32 %call.i, 0
138  br i1 %cmp2.i, label %if.end.i, label %do.end21
139
140if.end.i:                                         ; preds = %while.body.i
141  %21 = load i32 (i32, i32, i64, %struct._Unwind_Exception*, %struct._Unwind_Context*)*, i32 (i32, i32, i64, %struct._Unwind_Exception*, %struct._Unwind_Context*)** %personality.i, align 8
142  %tobool.i = icmp eq i32 (i32, i32, i64, %struct._Unwind_Exception*, %struct._Unwind_Context*)* %21, null
143  br i1 %tobool.i, label %if.end12.i, label %if.then3.i
144
145if.then3.i:                                       ; preds = %if.end.i
146  %or.i = select i1 %cmp.i, i32 6, i32 2
147  %22 = load i64, i64* %exception_class, align 8
148  %call5.i = call i32 %21(i32 1, i32 %or.i, i64 %22, %struct._Unwind_Exception* %exc, %struct._Unwind_Context* %cur_context)
149  switch i32 %call5.i, label %do.end21 [
150    i32 7, label %do.body19
151    i32 8, label %if.end12.i
152  ]
153
154if.end12.i:                                       ; preds = %if.then3.i, %if.end.i
155  br i1 %cmp.i, label %cond.true.i, label %cond.end.i
156
157cond.true.i:                                      ; preds = %if.end12.i
158  call void @abort() noreturn
159  unreachable
160
161cond.end.i:                                       ; preds = %if.end12.i
162  call fastcc void @uw_update_context_1(%struct._Unwind_Context* %cur_context, %struct._Unwind_FrameState* %fs.i)
163  %23 = load i64, i64* %retaddr_column.i22, align 8
164  %conv.i23 = trunc i64 %23 to i32
165  %cmp.i.i.i24 = icmp slt i32 %conv.i23, 18
166  br i1 %cmp.i.i.i24, label %cond.end.i.i.i33, label %cond.true.i.i.i25
167
168cond.true.i.i.i25:                                ; preds = %cond.end.i
169  call void @abort() noreturn
170  unreachable
171
172cond.end.i.i.i33:                                 ; preds = %cond.end.i
173  %sext.i26 = shl i64 %23, 32
174  %idxprom.i.i.i27 = ashr exact i64 %sext.i26, 32
175  %arrayidx.i.i.i28 = getelementptr inbounds [18 x i8], [18 x i8]* @dwarf_reg_size_table, i64 0, i64 %idxprom.i.i.i27
176  %24 = load i8, i8* %arrayidx.i.i.i28, align 1
177  %arrayidx2.i.i.i29 = getelementptr inbounds %struct._Unwind_Context, %struct._Unwind_Context* %cur_context, i64 0, i32 0, i64 %idxprom.i.i.i27
178  %25 = load i8*, i8** %arrayidx2.i.i.i29, align 8
179  %26 = load i64, i64* %flags.i.i.i.i, align 8
180  %and.i.i.i.i31 = and i64 %26, 4611686018427387904
181  %tobool.i.i.i32 = icmp eq i64 %and.i.i.i.i31, 0
182  br i1 %tobool.i.i.i32, label %if.end.i.i.i39, label %land.lhs.true.i.i.i36
183
184land.lhs.true.i.i.i36:                            ; preds = %cond.end.i.i.i33
185  %arrayidx4.i.i.i34 = getelementptr inbounds %struct._Unwind_Context, %struct._Unwind_Context* %cur_context, i64 0, i32 8, i64 %idxprom.i.i.i27
186  %27 = load i8, i8* %arrayidx4.i.i.i34, align 1
187  %tobool6.i.i.i35 = icmp eq i8 %27, 0
188  br i1 %tobool6.i.i.i35, label %if.end.i.i.i39, label %if.then.i.i.i37
189
190if.then.i.i.i37:                                  ; preds = %land.lhs.true.i.i.i36
191  %28 = ptrtoint i8* %25 to i64
192  br label %uw_update_context.exit44
193
194if.end.i.i.i39:                                   ; preds = %land.lhs.true.i.i.i36, %cond.end.i.i.i33
195  %cmp8.i.i.i38 = icmp eq i8 %24, 8
196  br i1 %cmp8.i.i.i38, label %if.then10.i.i.i40, label %cond.true14.i.i.i41
197
198if.then10.i.i.i40:                                ; preds = %if.end.i.i.i39
199  %29 = bitcast i8* %25 to i64*
200  %30 = load i64, i64* %29, align 8
201  br label %uw_update_context.exit44
202
203cond.true14.i.i.i41:                              ; preds = %if.end.i.i.i39
204  call void @abort() noreturn
205  unreachable
206
207uw_update_context.exit44:                         ; preds = %if.then10.i.i.i40, %if.then.i.i.i37
208  %retval.0.i.i.i42 = phi i64 [ %28, %if.then.i.i.i37 ], [ %30, %if.then10.i.i.i40 ]
209  %31 = inttoptr i64 %retval.0.i.i.i42 to i8*
210  store i8* %31, i8** %ra.i, align 8
211  br label %while.body.i
212
213do.body19:                                        ; preds = %if.then3.i
214  call void @llvm.lifetime.end(i64 -1, i8* %17)
215  %call20 = call fastcc i64 @uw_install_context_1(%struct._Unwind_Context* %this_context, %struct._Unwind_Context* %cur_context)
216  %32 = load i8*, i8** %ra.i, align 8
217  call void @llvm.eh.return.i64(i64 %call20, i8* %32)
218  unreachable
219
220do.end21.loopexit46:                              ; preds = %if.then4, %while.body
221  %retval.0.ph = phi i32 [ 3, %if.then4 ], [ 5, %while.body ]
222  br label %do.end21
223
224do.end21:                                         ; preds = %do.end21.loopexit46, %if.then3.i, %while.body.i, %while.body
225  %retval.0 = phi i32 [ %retval.0.ph, %do.end21.loopexit46 ], [ 3, %while.body ], [ 2, %while.body.i ], [ 2, %if.then3.i ]
226  ret i32 %retval.0
227}
228
229declare void @llvm.eh.unwind.init() nounwind
230
231declare fastcc void @uw_init_context_1(%struct._Unwind_Context*, i8*, i8*) uwtable
232
233declare i8* @llvm.eh.dwarf.cfa(i32) nounwind
234
235declare i8* @llvm.returnaddress(i32) nounwind readnone
236
237declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind
238
239declare fastcc i64 @uw_install_context_1(%struct._Unwind_Context*, %struct._Unwind_Context*) uwtable
240
241declare void @llvm.eh.return.i64(i64, i8*) nounwind
242
243declare fastcc void @uw_update_context_1(%struct._Unwind_Context*, %struct._Unwind_FrameState* nocapture) uwtable
244
245declare void @llvm.lifetime.start(i64, i8* nocapture) nounwind
246
247declare void @llvm.lifetime.end(i64, i8* nocapture) nounwind
248