xref: /llvm-project/llvm/test/Bindings/llvm-c/invoke.ll (revision e33af271eaed0bdaf6f95edd7c0841423fd0fc0e)
1; RUN: llvm-as < %s | llvm-dis > %t.orig
2; RUN: llvm-as < %s | llvm-c-test --echo > %t.echo
3; RUN: diff -w %t.orig %t.echo
4
5%C6object9ClassInfo = type { ptr, ptr }
6%C6object9ClassInfo__vtbl = type { ptr }
7%C6object9Exception__vtbl = type { ptr }
8%C6object6Object = type { ptr }
9%C6object6Object__vtbl = type { ptr }
10%C6object9Throwable = type { ptr }
11%C6object9Throwable__vtbl = type { ptr }
12
13@C6object9ClassInfo__ClassInfo = linkonce_odr constant %C6object9ClassInfo { ptr @C6object9ClassInfo__vtblZ, ptr @C6object8TypeInfo__ClassInfo }
14@C6object9ClassInfo__vtblZ = linkonce_odr constant %C6object9ClassInfo__vtbl { ptr @C6object9ClassInfo__ClassInfo }
15@C6object8TypeInfo__ClassInfo = linkonce_odr constant %C6object9ClassInfo { ptr @C6object9ClassInfo__vtblZ, ptr @C6object6Object__ClassInfo }
16@C6object6Object__ClassInfo = linkonce_odr constant %C6object9ClassInfo { ptr @C6object9ClassInfo__vtblZ, ptr @C6object6Object__ClassInfo }
17@C6object9Throwable__ClassInfo = linkonce_odr constant %C6object9ClassInfo { ptr @C6object9ClassInfo__vtblZ, ptr @C6object6Object__ClassInfo }
18@C6object9Exception__ClassInfo = linkonce_odr constant %C6object9ClassInfo { ptr @C6object9ClassInfo__vtblZ, ptr @C6object9Throwable__ClassInfo }
19@C6object9Exception__vtblZ = linkonce_odr constant %C6object9Exception__vtbl { ptr @C6object9Exception__ClassInfo }
20@C6object5Error__ClassInfo = linkonce_odr constant %C6object9ClassInfo { ptr @C6object9ClassInfo__vtblZ, ptr @C6object9Throwable__ClassInfo }
21
22define i32 @_D8test01494mainFMZi() personality ptr @__sd_eh_personality {
23body:
24  %0 = invoke noalias ptr @_d_allocmemory(i64 8)
25          to label %then unwind label %landingPad
26
27then:                                             ; preds = %body
28  store ptr bitcast (ptr @C6object9Exception__vtblZ to ptr), ptr %0, align 8
29  invoke void @_D6object6Object6__ctorFMC6object6ObjectZv(ptr %0)
30          to label %then1 unwind label %landingPad
31
32then1:                                            ; preds = %then
33  invoke void @__sd_eh_throw(ptr nonnull %0)
34          to label %then2 unwind label %landingPad
35
36then2:                                            ; preds = %then1
37  unreachable
38
39landingPad:                                       ; preds = %then1, %then, %body
40  %1 = landingpad { ptr, i32 }
41          cleanup
42          catch ptr @C6object5Error__ClassInfo
43          catch ptr @C6object9Exception__ClassInfo
44          catch ptr @C6object9Throwable__ClassInfo
45  %2 = extractvalue { ptr, i32 } %1, 1
46  %3 = tail call i32 @llvm.eh.typeid.for(ptr nonnull bitcast (ptr @C6object5Error__ClassInfo to ptr))
47  %4 = icmp eq i32 %3, %2
48  br i1 %4, label %catch, label %unwind3
49
50catch:                                            ; preds = %unwind5, %unwind3, %landingPad
51  %merge = phi i32 [ 23, %landingPad ], [ 19, %unwind3 ], [ 13, %unwind5 ]
52  ret i32 %merge
53
54unwind3:                                          ; preds = %landingPad
55  %5 = tail call i32 @llvm.eh.typeid.for(ptr nonnull @C6object9Exception__ClassInfo)
56  %6 = icmp eq i32 %5, %2
57  br i1 %6, label %catch, label %unwind5
58
59unwind5:                                          ; preds = %unwind3
60  %7 = tail call i32 @llvm.eh.typeid.for(ptr nonnull @C6object9Throwable__ClassInfo)
61  %8 = icmp eq i32 %7, %2
62  br i1 %8, label %catch, label %unwind7
63
64unwind7:                                          ; preds = %unwind5
65  resume { ptr, i32 } %1
66}
67
68declare void @_D6object6Object6__ctorFMC6object6ObjectZv(ptr)
69
70declare noalias ptr @_d_allocmemory(i64)
71
72declare i32 @__sd_eh_personality(i32, i32, i64, ptr, ptr)
73
74declare void @__sd_eh_throw(ptr nonnull) #0
75
76; Function Attrs: nounwind readnone
77declare i32 @llvm.eh.typeid.for(ptr) #1
78
79attributes #0 = { noreturn }
80attributes #1 = { nounwind readnone }
81