1 ; REQUIRES: x86_64-apple
2 ; RUN: lli -jit-kind=orc-lazy %s
4 ; Basic correctness testing for eh-frame processing and registration.
6 source_filename = "minimal-throw-catch.cpp"
7 target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
8 target triple = "x86_64-apple-macosx10.14.0"
10 @_ZTIi = external constant ptr
12 declare ptr @__cxa_allocate_exception(i64)
13 declare void @__cxa_throw(ptr, ptr, ptr)
15 declare i32 @__gxx_personality_v0(...)
16 declare i32 @llvm.eh.typeid.for(ptr)
17 declare ptr @__cxa_begin_catch(ptr)
18 declare void @__cxa_end_catch()
20 define void @explode() {
22 %exception = tail call ptr @__cxa_allocate_exception(i64 4)
23 store i32 42, ptr %exception, align 16
24 tail call void @__cxa_throw(ptr %exception, ptr @_ZTIi, ptr null)
28 define i32 @main(i32 %argc, ptr %argv) personality ptr @__gxx_personality_v0 {
30 invoke void @explode()
31 to label %return unwind label %lpad
34 %0 = landingpad { ptr, i32 }
36 %1 = extractvalue { ptr, i32 } %0, 1
37 %2 = tail call i32 @llvm.eh.typeid.for(ptr @_ZTIi)
38 %matches = icmp eq i32 %1, %2
39 br i1 %matches, label %catch, label %eh.resume
42 %3 = extractvalue { ptr, i32 } %0, 0
43 %4 = tail call ptr @__cxa_begin_catch(ptr %3)
44 %5 = load i32, ptr %4, align 4
45 %cmp = icmp ne i32 %5, 42
46 %cond = zext i1 %cmp to i32
47 tail call void @__cxa_end_catch()
51 %retval.0 = phi i32 [ %cond, %catch ], [ 2, %entry ]
55 resume { ptr, i32 } %0