1 ; RUN: llc -mtriple x86_64-unknown-unknown -exception-model sjlj -verify-machineinstrs=0 -simplifycfg-require-and-preserve-domtree=1 < %s | FileCheck %s --check-prefix=NUM
2 ; RUN: llc -mtriple x86_64-unknown-unknown -exception-model sjlj -verify-machineinstrs=0 -simplifycfg-require-and-preserve-domtree=1 < %s | FileCheck %s --check-prefix=SJLJ
7 ;SJLJ-NEXT: .Lfunc_begin0:
8 ;SJLJ-NEXT: # %bb.0: # %entry
10 ;SJLJ-NEXT: pushq %rbp
11 ;SJLJ: callq _Unwind_SjLj_Register
13 ;SJLJ-NEXT: callq _Z3foov
15 ;SJLJ-NEXT: # %bb.1: # %invoke.cont
17 ;SJLJ-NEXT: .LBB0_7: # %return
18 ;SJLJ: callq _Unwind_SjLj_Unregister
24 ;SJLJ-NEXT: jb .LBB0_10
28 ;SJLJ-NEXT: leaq .LJTI0_0(%rip), %rcx
29 ;SJLJ-NEXT: jmpq *(%rcx,%rax,8)
30 ;SJLJ-NEXT: .LBB0_2: # %lpad
34 ;SJLJ-NEXT: # %bb.3: # %catch3
35 ;SJLJ: callq __cxa_begin_catch
37 ;SJLJ-NEXT: .LBB0_4: # %catch.fallthrough
39 ;SJLJ-NEXT: jne .LBB0_8
40 ;SJLJ-NEXT: # %bb.5: # %catch
41 ;SJLJ: callq __cxa_begin_catch
43 ;SJLJ-NEXT: .LBB0_6: # %return
44 ;SJLJ: callq __cxa_end_catch
45 ;SJLJ-NEXT: jmp .LBB0_7
46 ;SJLJ-NEXT: .LBB0_8: # %eh.resume
48 ;SJLJ-NEXT: .Lfunc_end0:
50 ;SJLJ-NEXT: .quad .LBB0_2
52 @_ZTIi = external dso_local constant ptr
53 @_ZTIc = external dso_local constant ptr
55 ; Function Attrs: noinline norecurse optnone uwtable
56 define dso_local i32 @main() #0 personality ptr @__gxx_personality_sj0 {
58 %retval = alloca i32, align 4
59 %exn.slot = alloca ptr
60 %ehselector.slot = alloca i32
61 %x = alloca i8, align 1
62 %x4 = alloca i32, align 4
63 store i32 0, ptr %retval, align 4
64 invoke void @_Z3foov()
65 to label %invoke.cont unwind label %lpad
67 invoke.cont: ; preds = %entry
70 lpad: ; preds = %entry
71 %0 = landingpad { ptr, i32 }
74 %1 = extractvalue { ptr, i32 } %0, 0
75 store ptr %1, ptr %exn.slot, align 8
76 %2 = extractvalue { ptr, i32 } %0, 1
77 store i32 %2, ptr %ehselector.slot, align 4
78 br label %catch.dispatch
80 catch.dispatch: ; preds = %lpad
81 %sel = load i32, ptr %ehselector.slot, align 4
82 %3 = call i32 @llvm.eh.typeid.for(ptr @_ZTIi) #3
83 %matches = icmp eq i32 %sel, %3
84 br i1 %matches, label %catch3, label %catch.fallthrough
86 catch3: ; preds = %catch.dispatch
87 %exn5 = load ptr, ptr %exn.slot, align 8
88 %4 = call ptr @__cxa_begin_catch(ptr %exn5) #3
89 %5 = load i32, ptr %4, align 4
90 store i32 %5, ptr %x4, align 4
91 %6 = load i32, ptr %x4, align 4
92 %cmp6 = icmp ne i32 %6, 5
93 %conv7 = zext i1 %cmp6 to i32
94 store i32 %conv7, ptr %retval, align 4
95 call void @__cxa_end_catch() #3
98 catch.fallthrough: ; preds = %catch.dispatch
99 %7 = call i32 @llvm.eh.typeid.for(ptr @_ZTIc) #3
100 %matches1 = icmp eq i32 %sel, %7
101 br i1 %matches1, label %catch, label %eh.resume
103 catch: ; preds = %catch.fallthrough
104 %exn = load ptr, ptr %exn.slot, align 8
105 %8 = call ptr @__cxa_begin_catch(ptr %exn) #3
106 %9 = load i8, ptr %8, align 1
107 store i8 %9, ptr %x, align 1
108 %10 = load i8, ptr %x, align 1
109 %conv = sext i8 %10 to i32
110 %cmp = icmp ne i32 %conv, 3
111 %conv2 = zext i1 %cmp to i32
112 store i32 %conv2, ptr %retval, align 4
113 call void @__cxa_end_catch() #3
116 try.cont: ; preds = %invoke.cont
117 store i32 1, ptr %retval, align 4
120 return: ; preds = %try.cont, %catch3, %catch
121 %11 = load i32, ptr %retval, align 4
124 eh.resume: ; preds = %catch.fallthrough
125 %exn8 = load ptr, ptr %exn.slot, align 8
126 %sel9 = load i32, ptr %ehselector.slot, align 4
127 %lpad.val = insertvalue { ptr, i32 } undef, ptr %exn8, 0
128 %lpad.val10 = insertvalue { ptr, i32 } %lpad.val, i32 %sel9, 1
129 resume { ptr, i32 } %lpad.val10
132 declare dso_local void @_Z3foov() #1
134 declare dso_local i32 @__gxx_personality_sj0(...)
136 ; Function Attrs: nounwind readnone
137 declare i32 @llvm.eh.typeid.for(ptr) #2
139 declare dso_local ptr @__cxa_begin_catch(ptr)
141 declare dso_local void @__cxa_end_catch()
143 !llvm.module.flags = !{!0, !1, !2}
145 !0 = !{i32 1, !"wchar_size", i32 4}
146 !1 = !{i32 8, !"cf-protection-return", i32 1}
147 !2 = !{i32 8, !"cf-protection-branch", i32 1}