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