1 ; REQUIRES: system-darwin
2 ; RUN: lli -jit-kind=orc-lazy %s
4 ; Sanity test 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-f80:128-n8:16:32:64-S128"
8 target triple = "x86_64-apple-macosx10.14.0"
10 @_ZTIi = external constant i8*
12 declare i8* @__cxa_allocate_exception(i64)
13 declare void @__cxa_throw(i8*, i8*, i8*)
15 declare i32 @__gxx_personality_v0(...)
16 declare i32 @llvm.eh.typeid.for(i8*)
17 declare i8* @__cxa_begin_catch(i8*)
18 declare void @__cxa_end_catch()
20 define void @explode() {
22 %exception = tail call i8* @__cxa_allocate_exception(i64 4)
23 %0 = bitcast i8* %exception to i32*
24 store i32 42, i32* %0, align 16
25 tail call void @__cxa_throw(i8* %exception, i8* bitcast (i8** @_ZTIi to i8*), i8* null)
29 define i32 @main(i32 %argc, i8** %argv) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
31 invoke void @explode()
32 to label %return unwind label %lpad
35 %0 = landingpad { i8*, i32 }
36 catch i8* bitcast (i8** @_ZTIi to i8*)
37 %1 = extractvalue { i8*, i32 } %0, 1
38 %2 = tail call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*))
39 %matches = icmp eq i32 %1, %2
40 br i1 %matches, label %catch, label %eh.resume
43 %3 = extractvalue { i8*, i32 } %0, 0
44 %4 = tail call i8* @__cxa_begin_catch(i8* %3)
45 %5 = bitcast i8* %4 to i32*
46 %6 = load i32, i32* %5, align 4
47 %cmp = icmp ne i32 %6, 42
48 %cond = zext i1 %cmp to i32
49 tail call void @__cxa_end_catch()
53 %retval.0 = phi i32 [ %cond, %catch ], [ 2, %entry ]
57 resume { i8*, i32 } %0