1; RUN: llc < %s | FileCheck %s
2target datalayout = "e-p:32:32:32-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:64:128-a0:0:64-n32-S64"
3target triple = "armv7-none-linux-gnueabi"
4
5@_ZTIi = external constant i8*
6
7declare void @_Z3foov() noreturn;
8
9declare i8* @__cxa_allocate_exception(i32)
10
11declare i32 @__gxx_personality_v0(...)
12
13declare void @__cxa_throw(i8*, i8*, i8*)
14
15declare void @__cxa_call_unexpected(i8*)
16
17define i32 @main() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
18; CHECK-LABEL: main:
19entry:
20  %exception.i = tail call i8* @__cxa_allocate_exception(i32 4) nounwind
21  %0 = bitcast i8* %exception.i to i32*
22  store i32 42, i32* %0, align 4
23  invoke void @__cxa_throw(i8* %exception.i, i8* bitcast (i8** @_ZTIi to i8*), i8* null) noreturn
24          to label %unreachable.i unwind label %lpad.i
25
26lpad.i:                                           ; preds = %entry
27  %1 = landingpad { i8*, i32 }
28          filter [1 x i8*] [i8* bitcast (i8** @_ZTIi to i8*)]
29          catch i8* bitcast (i8** @_ZTIi to i8*)
30; CHECK: .long	_ZTIi(target2)          @ TypeInfo 1
31; CHECK: .long	_ZTIi(target2)          @ FilterInfo -1
32  %2 = extractvalue { i8*, i32 } %1, 1
33  %ehspec.fails.i = icmp slt i32 %2, 0
34  br i1 %ehspec.fails.i, label %ehspec.unexpected.i, label %lpad.body
35
36ehspec.unexpected.i:                              ; preds = %lpad.i
37  %3 = extractvalue { i8*, i32 } %1, 0
38  invoke void @__cxa_call_unexpected(i8* %3) noreturn
39          to label %.noexc unwind label %lpad
40
41.noexc:                                           ; preds = %ehspec.unexpected.i
42  unreachable
43
44unreachable.i:                                    ; preds = %entry
45  unreachable
46
47lpad:                                             ; preds = %ehspec.unexpected.i
48  %4 = landingpad { i8*, i32 }
49          catch i8* bitcast (i8** @_ZTIi to i8*)
50  br label %lpad.body
51
52lpad.body:                                        ; preds = %lpad.i, %lpad
53  %eh.lpad-body = phi { i8*, i32 } [ %4, %lpad ], [ %1, %lpad.i ]
54  %5 = extractvalue { i8*, i32 } %eh.lpad-body, 1
55  %6 = tail call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*)) nounwind
56  %matches = icmp eq i32 %5, %6
57  br i1 %matches, label %try.cont, label %eh.resume
58
59try.cont:                                         ; preds = %lpad.body
60  %7 = extractvalue { i8*, i32 } %eh.lpad-body, 0
61  %8 = tail call i8* @__cxa_begin_catch(i8* %7) nounwind
62  tail call void @__cxa_end_catch() nounwind
63  ret i32 0
64
65eh.resume:                                        ; preds = %lpad.body
66  resume { i8*, i32 } %eh.lpad-body
67}
68
69declare i32 @llvm.eh.typeid.for(i8*) nounwind readnone
70
71declare i8* @__cxa_begin_catch(i8*)
72
73declare void @__cxa_end_catch()
74